Reputation: 4955
I have the following situation: My git repository had broken .project files checked in previously, and we wanted to remove them as they cause all sorts of importing issues. So I created a branch, where I removed all the .project files, added ".project" to .gitignore, and had planned to merge it into master, have all the developers pull down the latest update, and reimport. I've tested this and it works fine...new metadata (ie .project) files are created by Eclipse, but are ignored because of the .gitignore change.
The problem is, if a developer switches to one of their issue branches which was created pre-fix, that branch will still have the old (incorrect) .project files, which when checking out will overwrite what eclipse just generated in their working directory. This breaks everything...
I tried "update-index --skip-worktree" and "--assume-unchanged", but it wouldn't work properly, I assume because these files were no longer in the index and were ignored. Is there any way, short of merging master back into all of their branches before telling them to reimport everything, that I can resolve this?
Thanks.
EDIT: I should note, while I'm pretty experienced with git, the developers on my team are complete novices. So ideally any solution would be one that I could do on the repo side, and they could just click "pull" and have everything work automagically. If there was a single command that they could run through the SourceTree console, that might work too...
Upvotes: 0
Views: 264
Reputation: 17455
Likely, if you can negotiate with all users of your repository, then the most suitable way for you would be to rewrite the whole repository, erasing the file completely. Use git filter-branch, something like this:
git filter-branch --tree-filter 'rm -f .project && \
if ! test -f .gitignore || ! grep -q "^\.project$" .gitignore; \
then \
echo .project >>.gitignore; \
fi' -- --all
If your repository is large enough then you probably wish to use --index-filter
instead of --tree-filter
because --index-filter
operates directly on git DB without checking out of every commit in the repository. But the script for --index-filter
is more complex and cumbersome.
Then, after repository is rewritten and you have checked that every commit in every branch received desired changes, then all developers should re-fetch the repo. It would be better to ask them to push all their local changes to the repository before you start to minimize the work of rebasing when they receive the modified repository.
Upvotes: 1