Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I ask git to clean out and rebuild the entire working tree?

We have something of an ugly mess that needs cleaning up.

In our codebase, certain developers created directories whose name differed only in case. Normally, such a thing would not be an issue; however we are developing on Windows. This proceeded to confuse git and cause us merge conflicts far down the line.

We have since pushed changes to master getting rid of the duplicate directories in the tree (and encountering some Azure DevOps bugs in the process); now all that remains is a large number of incorrect directory names on users’ workstations. Due to the case interactions between git and Windows; these won’t get cleaned up by a git pull.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do we actually erase and rebuild the working trees without throwing out the local branch state in .git? I need to send out instructions so everybody on the team can clean this mess up and those wrong-case local directories don’t magically reappear in future commits.

>Solution :

Delete all files and then do a git reset --hard.

git rm -r .
# might need an additional rm outside of git if there are directories left over there
git reset --hard

Just be careful not to have any uncommitted changes hanging around.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading