6

I am working on a web app with Angular JS. After Commit, I am trying to Pull the latest version of the other web developer to merge it with mine before I Push my latest changes. I am getting this error and don't know why is this happening because I had no problem on the previous pull / push.

error: The following untracked working tree files would be overwritten by merge:
.gitignore
Please move or remove them before you can merge.
Stewie
  • 60,366
  • 20
  • 146
  • 113
user3333901
  • 61
  • 1
  • 1
  • 2
  • This means someone has added a `.gitignore` to the repo you are pulling. If you were to merge, your local `.gitignore` would be overwritten and lost forever. – bnjmn Feb 20 '14 at 17:38
  • `git` is also unable to merge your changes to `.gitignore` in, so merge them manually. – simonzack Feb 20 '14 at 17:39
  • 2
    You can A) just delete your local copy and perform the merge, or B) commit your local copy and then handle the conflict on merge – bnjmn Feb 20 '14 at 17:39
  • possible duplicate of [Git error: The following untracked working tree files would be overwritten by checkout](http://stackoverflow.com/questions/4858047/git-error-the-following-untracked-working-tree-files-would-be-overwritten-by-ch) – Steve Chambers Oct 21 '14 at 08:34

1 Answers1

5

It appears you have created a local .gitignore file but have not commited it to the repository and the remote you are attempting to interact with (pull/push) now has a .gitignore. This would be the case for any file in your repo when this happens

Since .gitignore is not just any file, it affects the way git behaves, I would compare the two manually, create a file that is a union of the two, commit it and then merge, fixing any formatting issues that might exist.

These could be the exact same file, but git wouldn't know because you haven't added it locally. This isn't a file you want to be changing often because it can make checkouts behave differently.

Github maintains a list of useful .gitignore templates for most languages.

bnjmn
  • 4,508
  • 4
  • 37
  • 52