Skip to main content

How to remove a file from GIT history

GIT, a source code management tool is famous among developers. Often times, developers miss to realise or understand .gitignore file in GIT (a most popular open source repository tool). This file helps to avoid unrelated files getting into the project repository. As a newbie to GIT, developers miss to add .gitignore and hence we get to see unwanted files or binaries added in the project repository. This may sometimes lead to issues for other developers.

So, how do we remove a file from GIT history that should not have been added in the first place? Git has numerous commands of which git filter-branch can help us in this scenario.

For example: 
.iml files are Intellij editor files that will be created for each module. Lets suppose a developer (newbie) added this .iml file in project repository unknowingly. An other developer imports project modules in his/her IntelliJ editor. Then the latter will see *.iml as modified file. But this should not have been considered for project repository. So Lets help this other developer to remove this *.iml file using git filter-branch command.

git filter-branch --index-filter "git rm --cached --ignore-unmatch *.iml" HEAD

On executing the above command, git finds all the commits and remove *.iml files and rewrite the history. This will ensure *.iml file removed from GIT history at all. A word of caution, for larger projects, this command may take time to complete as it has to go through all the commits in the branch mentioned (HEAD). After the successful execution of the command, the other developer can add *.iml in .gitignore file so it never gets considered for Project Repository Tracking.

For more on this command, please visit git-filter-branch

Caveat: If the file can be removed using single commit, please refrain from using the above command, and use the normal commit to achieve what you need.

Comments

  1. Experts at Edumagnate comprehend the student's lifestyle and their willingness to learn. We have the most experienced and qualified professionals who are capable of producing plagiarism-free high-quality content. Our writing teams ensure that you will score the highest marks in the assignments. We promise content with zero numbers of grammatical errors. Our team is well-known for the authenticity, as we offer qualitative and genuine content before the deadline. With us, you get both quantity and quality at the same time.

    ReplyDelete
  2. Generally, I don’t learn article on blogs, but I would like to say that this write-up pressured me to check out and do so! Your writing style has been amazing me. Thanks, quite a great post. is uniport post utme form out

    ReplyDelete
  3. It is so interesting i was searching for this topic from a long time. I read this article very carefully and now I got all my best information. business tips helping your style business research topics

    ReplyDelete
  4. หากคุณเป็นคนที่ถูกอกถูกใจแทงหวยหุ้นอยู่แล้วล่ะก็ วันนี้เราขอเสนอแนะสูตรแทง หวยออนไลน์ ล็อตเตอรี่หุ้นพื้นที่เว็บ lottovip ของเรามีให้บริการซึ่งเป็นหวยหุ้นทางวิชาเลขคณิตเพื่อใช้เป็นแนวทางในการเล่นหวยนั่นเอง ซึ่งขณะนี้สลากกินแบ่งออนไลน์ถือว่ามีนาทุ่งนาประการต้นแบบโดยเฉพาะล็อตเตอรี่หุ้น พูดได้ว่าเป็นที่พึงพอใจรวมทั้งกำลังมาแรง ด้วยรอบเปิดที่สามารถเล่นได้มากถึง 4 รอบต่อวัน

    ทำให้ผู้ถูกใจการพนันมีความสนุกสนานแล้วก็ร่วมลุ้นไปกับเงินรางวัลได้มากขึ้นอีกด้วย รวมทั้งสำหรับแฟนสลากกินแบ่งหุ้นวันนี้ ทางเว็บ lottovip เราก็ไม่พลาดที่จะนำเรื่องราวข้อมูลและข้อมูลมาฝาก สำหรับสูตรล็อตเตอรี่หุ้นที่มีมานาน

    รวมทั้งสามารถที่จะนำไปใช้ได้ตลอด lottovip มาแชร์ให้สมาชิกเพื่อเป็นแนวทางในการคำนวณล็อตเตอรี่ทุกๆวันแม่นๆกันจ้ะจะเป็นอย่างไรนั้นตามไปติดตามรับมองกันได้เลยคะ

    ReplyDelete
  5. casino【阅读全文】casino games for Android
    casino,【阅读全文】casino 배트맨토토 games for Android,casino air jordan 18 retro red free shipping games for Android,online new air jordan 18 stockx casino for android,games for android,games best air jordan 18 retro men red for what is the best air jordan 18 stockx android

    ReplyDelete
  6. สล็อต g2g สล็อตร่ำรวยเร็ว ถอนได้ไม่ยั้ง เล่นสนุกสนาน จบครบในเว็บไซต์เดียว ระบบมาตรฐาน ด้วยคณะทำงานที่มีประสบการณ์กว่า 10 ปี pg slot แต่ว่ามั่นคง เป็นแหล่งรวมเกมที่มีแบบงาม

    ReplyDelete

Post a Comment

Popular posts from this blog

CSRF enabled Ajax requests using Spring Security

Many of you who have worked on Spring Security might be aware of the fact that Spring Security protects applications from Cross Site Request Forgery using _csrf tokens in the request sent to the web server. You can find a detailed understanding in the Spring documentation page . The objective of this post is to explain how to send _csrf tokens in the Ajax requests when we protect our application URL and application access using spring security. How to get CSRF tokens While we submit a form using an application that is protected with Spring Security, the form gets a default hidden parameter in the form body when using <form:form> element. The param contains the _csrf tokens to authenticate the requests in the server. In case we use other ways to create forms, we have to manually include a hidden parameter that contains name as ${_csrf.parameterName} and  value as ${_csrf.token} . For example, <input type= "hidden" name= "${_csrf.parameterName}"

A wonderful technique to reduce website development cost

Websites - Good way to get online presence Websites are very vital to get online presence of any business nowadays. Websites are categorized into two different types. First one is Static Website and second one is Dynamic Website, normally known as web applications. Static websites are most widely used for any business since they help to bring up the online presence more easily and quickly. Depending on the content and features, static websites cost around $300-$700 . It includes web design and development. Apart from that, the business has to spend for hosting space and domain name for the website. Cloud based development is now more prevalent. Building a website and running it will be very easy and cheap using these cloud infrastructure. But the difficulty facing the development of static websites still looms high as it does not matter who provides the infrastructure. The development cost is still same. Technology - LAMP Static websites are developed using HTML and PHP mostly

In-Place editing with X-Editable using Datatable plugin

Introduction In-place editing is a trending feature that can be seen in many latest web applications, a popular example would be trello.com where the editing data happens on the web page without any explicit forms or popups. Another such example I could point out is, thoughtplan.com. The in-place editing is very nice in such a way that editing data seems so natural and user friendly. To enable in-place editing, there are many free JQuery plugins available on the internet. We are discussing a very popular plugin called x-editable . Most of the time we use html tables to display data where in-place editing is enabled. Hence we need another plugin to elegantly display tables with enormous data. We use a famous JQuery plugin called datatable . Both of these plugins are used widely and free to use. Assumption      : Bootstrap 3, JQuery used Projects Integration In order to enable datatable features on any ordinary table found on web page, we should initialise datatable plugin for