tags:

views:

43

answers:

6

I have a tracked database (already added) file in git. I want this file be always set to a certain state in my repository. Even when I modify it for test purposes.

With git, how to exclude (not permanently) this changed already tracked file from a commit ?

A: 
  1. add this file to your repo
  2. commit
  3. add it to .gitignore file
  4. commit .gitignore file
zed_0xff
This makes my head hurt, but is probably more elegant than my suggestion
jdizzle
This solution does not work because the file is already tracked, is'n it?
djondal
-1. This just does not work. The file is still shown in `git status` as modified.
Pavel Shved
+1  A: 

If you don't do git commit -a, git commit will only commit files that you have explicitly added to the index using git add.

jdizzle
However, it's tedious to memorize, which files you should add, and which you should not.
Pavel Shved
A: 

simply do not add it with git add, but add any other file you want to commit

then use git commit instead of git commit -a

opatut
+5  A: 

The way to ignore certain files that are already committed is

git update-index --assume-unchanged file

However, this is a local setting, and it doesn't propagate when cloning.

Its effect is canceled with git update-index --no-assume-unchanged gui.

Pavel Shved
This a local setting, that is exactly what I am looking for
djondal
A: 

The smarter way to do this is to not track the database at all, directly. Track an example database and then each developer can copy it and modify it, and it can be under gitignore.

Daenyth
-1. Not helpful. Anyway, sometimes you can't do this because external framework **modifies** file during build, and can't generate it at the same time.
Pavel Shved
If my file is tracked, it is because it should be tracked...It is just that I do not want to propagate the changes I make on a testing level.
djondal
So in other words you want to track a base set of it and modify it locally... which is exactly what my solution lets you do.
Daenyth
+2  A: 

Additionally to using git add I would suggest to use a shell with more capabilities, i.e. zsh. Here you can insert extended globbing like *~*.o(.) which means all files except such ending with o. This make it easier to add all files except one. Zsh also allows you to set a global alias: alias -g AF="*~*.o(.)". So you can type git add AF and it will be expanded in the right way.

qbi