Can I commit a file with git but automatically ignore it when running git svn dcommit?

Now I'm starting to accept Git for my personal SVN office workflow, so git-svn is the tool I'll describe pretty much about. One problem I ran into that I don't know how to solve 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 use git-svn, I don't plan on using any of them. I replaced them in my local build.xml with Git equivalents that work fine.

However, I clearly don't want to commit this change to Git svn dcommit. I want to save this change locally and commit it locally so I don't lose it, but I don't want it to ever go back to the main SVN repo because it would pretty much break company-wide SVN usage if I do. A similar case using only SVN is presented in this question .

Is there any solution to allow me to compile build.xml locally, continue to accept build.xml changes from SVN (which also has a lot of non SVN stuff), and never back up it using dcommit without jumping over hoops every time I try to commit?

+3


source to share


1 answer


Yes, you can.

As you noted, you cannot gitignore

files that are already tracked. But what you can do is tell your index to pretend that no changes exist for certain files:

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

      



If you want to stop ignoring changes for this file (for example, because you made changes to build.xml

that you need to share with other team members), use:

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

      

Warning: if you directly add file with git add <file>

, it will assume that you really want to add that file and the directive --assume-unchanged

will be ignored.

+5


source







All Articles