Question

I'm starting now to adopt Git for my personal workflow at an SVN office, so git-svn is a tool I'm going to be relying on heavily. One issue I've come across that I don't know how to resolve is how to ignore in one direction.

The specific use case for me is that our ant build file references things like svn and svnversion. Obviously, if I'm using git-svn, I'm not planning on using either of those. I have replaced them in my local build.xml with git equivalents, which are working just fine.

However, I clearly don't want to commit that change in a git svn dcommit. I want to keep this change locally, and commit it locally so I don't lose it, but I don't want it to ever get committed back to the main SVN repo, because it will break pretty much the entire company's use of SVN, if I do. A similar case using SVN alone is presented in this question.

Is there any solution that would allow me to commit build.xml locally, continue to take build.xml changes from SVN (which has a lot of stuff not related to SVN as well), and never commit it back up using dcommit, without jumping through hoops every time I try to commit?

Was it helpful?

Solution

Yes, you can.

As you noted, you can't gitignore files that are already tracked. But what you can do is tell your index that it should pretend that no changes exist for certain files:

git update-index --assume-unchanged <file>

If you want to stop ignoring changes for that file (for example, because you made a change to build.xml that you do need to share with other team members), then use:

git update-index --no-assume-unchanged <file>

Warning: if you directly add the file with git add <file>, it will assume that you really mean that you want to add that file, and the --assume-unchanged directive will be ignored.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top