2

Let's say I have file secret_config in .git/info/exclude. My colleague, who doesn't know about this file, thinks file with such name might look shiny in his repository, so he creates, commits and pushes it. I, in good mood, want to pull, as every morning, but git starts to yell at me:

error: Untracked working tree file 'secret_config' would be overwritten by merge. Aborting

How to tell git to stop yelling at me? Is it possible to tell him to completely ignore this file even while pulling or fetching/merging?

Edit:

When I temporarily create .gitignore and put secret_config to it, it, at least, allows me to pull properly. I need to emulate this functionality somehow.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
  • Here's [another](http://stackoverflow.com/questions/1836742/using-git-how-do-i-ignore-a-file-in-one-branch-but-have-it-committed-in-another/4044387#4044387) post that may be relevent – Andy Jul 21 '11 at 17:46

2 Answers2

0

You can share your list of ignored files via .gitignore, e.g.

$ mv .git/info/exclude .gitignore
$ git add .gitignore
$ git commit -v "Add ignored file list"
$ git push

Next time he pulls he will inherit your list of ignored files. This doesn't fix the history of files he already committed in his repository though.

Benjamin Bannier
  • 55,163
  • 11
  • 60
  • 80
0

It's not exactly a solution, but there's possibility to change merging strategy, so file always keeps your local version. You just need to create file .gitattributes in the same directory as file you want to prevent merging and put name_of_file merge=ours in it. Downside is, you have to commit this file, so it feels like polluting repository with junk that no one but you needs.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126