git pull not ignoring the file which has been sent to the temporary ignore list
Hi,
I asked git not to track any changes to the file .gitignore. To do so I did use the command - git update-index --assume-unchanged .gitignore.
[arup@sztukajedzenia]$ git status
# On branch MajorUpgrade
# Your branch is behind 'origin/MajorUpgrade' by 4 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
[arup@sztukajedzenia]$ git pull origin MajorUpgrade
From rubyxcube.co.uk:sztuka-jedzenia/sztukajedzenia
* branch MajorUpgrade -> FETCH_HEAD
Updating 59a1c07..d7b9cd3
error: Your local changes to the following files would be overwritten by merge:
.gitignore
Please, commit your changes or stash them before you can merge.
Aborting
[arup@sztukajedzenia]$But you can see above, while I am taking pull, it is considering the file .gitignore. How should I tell git pull also not to consider the change the file, and skip it or something else ?
Signature · 7 lines
================ Regards, Arup Rakshit ================ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian Kernighan
Quoted 3 lines · Arup Rakshit
I asked git not to track any changes to the file .gitignore. To do so I did use the command - git update-index --assume-unchanged .gitignore.
You are not asking Git to do anything. You promised Git that you will make no changes to .gitignore, and then broke that promise.
Assume-unchanged is *not* "Ignore changes to this path".
Quoted 10 lines · you
Quoted 3 lines · Arup Rakshit
I asked git not to track any changes to the file .gitignore. To do so I did use the command - git update-index --assume-unchanged .gitignore.
You are not asking Git to do anything. You promised Git that you will make no changes to .gitignore, and then broke that promise.
Assume-unchanged is *not* "Ignore changes to this path".
Ok. How should I then ignore any local changes to the .gitignore file ? And while taking pull, git should skip this file ?
Signature · 7 lines
================ Regards, Arup Rakshit ================ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian Kernighan
Quoted 7 lines · Arup Rakshit
Quoted 6 lines · you
Quoted 3 lines · Arup Rakshit
I asked git not to track any changes to the file .gitignore. To do so I did use the command - git update-index --assume-unchanged .gitignore.
Quoted 6 lines
Quoted 4 lines
You are not asking Git to do anything. You promised Git that you will make no changes to .gitignore, and then broke that promise.
Assume-unchanged is *not* "Ignore changes to this path".
Ok. How should I then ignore any local changes to the .gitignore file ? And while taking pull, git should skip this file ?
Look at .git/info/exclude
When looking for a reference to that path (I am bad at remembering which man page that is)
I found https://help.github.com/articles/ignoring-files/ as Googles first hit, which advises to use
git update-index --assume-unchanged path/to/file.txt
Not sure if that is most helpful advice there.
See http://git-scm.com/docs/gitignore instead
Quoted 4 lines · Stefan Beller
Quoted 2 lines
Ok. How should I then ignore any local changes to the .gitignore file ? And while taking pull, git should skip this file ?
Look at .git/info/exclude
Good answer for ".gitignore". In general, you do not "ignore local changes" to tracked paths.
Quoted 4 lines
I found https://help.github.com/articles/ignoring-files/ as Googles first hit, which advises to use
git update-index --assume-unchanged path/to/file.txtNot sure if that is most helpful advice there.
The piece of advice in the last paragraph on that page is wrong (and it has been wrong from the day it was written).
The gitignore(5) documentation used to have a similar incorrect piece of advice but we finally corrected it recently.
Cf. http://thread.gmane.org/gmane.comp.version-control.git/260954/focus=261118
Quoted 9 lines · you
Quoted 4 lines · Stefan Beller
Quoted 2 lines
Ok. How should I then ignore any local changes to the .gitignore file ? And while taking pull, git should skip this file ?
Look at .git/info/exclude
Good answer for ".gitignore". In general, you do not "ignore local changes" to tracked paths.
There are some configuration files, like database.yml, where we generally put our local DB credentials and we don't want to share such things. That's why we always put related settings inside the .gitignore file. But while I will change it, git will not track the changes of the file, but .gitignore. That's why I used the first thread command. But when the time the came to take a git pull, I got to know about the mess. What should be the ideal decision in this case ?
Quoted 4 lines
Quoted 4 lines
I found https://help.github.com/articles/ignoring-files/ as Googles first hit, which advises to use
git update-index --assume-unchanged path/to/file.txtNot sure if that is most helpful advice there.
Yes, I followed the same.
Quoted 7 lines
The piece of advice in the last paragraph on that page is wrong (and it has been wrong from the day it was written).
The gitignore(5) documentation used to have a similar incorrect piece of advice but we finally corrected it recently.
Cf. http://thread.gmane.org/gmane.comp.version-control.git/260954/focus=261118
Signature · 7 lines
================ Regards, Arup Rakshit ================ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian Kernighan
Quoted 4 lines · Arup Rakshit
On Friday, January 23, 2015 01:14:03 PM you wrote:
[..]
Quoted 9 lines
There are some configuration files, like
database.yml, where we generally put our local DB credentials and we don't want to share such things. That's why we always put related settings inside the .gitignore file. But while I will change it, git will not track the changes of the file, but .gitignore. That's why I used the first thread command. But when the time the came to take agit pull, I got to know about the mess. What should be the ideal decision in this case ?
In an ideal sittuation, configuration data is not stored inside git, because this would tie the code only to one environment.
So what you would store in git is a template of the configuration data, that can be used to create the actual config file that is used.
This way, you don't have any problems with having to change tracked files only for you local environment.
Quoted 4 lines · Junio C Hamano
Good answer for ".gitignore". In general, you do not "ignore local changes" to tracked paths.
I assumed Arup would want to ignore more than is in the upstream project, so you'd come up with an appendix to the .gitignore file because that file is rather obvious to find (it's printed when git pull modifies it, 'ls' just find it,
you'd not look into .git/info/exclude by chance)
Assuming you want to ignore less than the upstream project (delete some lines from .gitignore) it get's tricky in my opinion. Either have a local commit and just use 'git pull' to resolve the conflicts with upstream. The problem then arises if you want to publish your changes (such as pushing your changes and creating a pull request, then you have that commit included, which you maybe don't want to include)
Mind, that I am talking about possible work flows to circumvent an assumed problem
which would result in problems as described in the first mail.
Quoted 2 lines · Stefan Beller
Assuming you want to ignore less than the upstream project (delete some lines from .gitignore) it get's tricky in my opinion.
Why? Doesn't info/exclude allow negative ignore patterns?
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Stefan Beller
Assuming you want to ignore less than the upstream project (delete some lines from .gitignore) it get's tricky in my opinion.
Why? Doesn't info/exclude allow negative ignore patterns?
I used negative patterns only once, so they did not come to my mind today. Apologies for not looking it up before replying. :(