doub1ejack
doub1ejack

Reputation: 11171

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

What do I have to do to get around this "already up-to-date" error:

I created a new local repo and tried to pull the remote master branch. It stumbled over my new .gitignore and errored out. I deleted the .gitignore (to be replaced with the repo's), but now I can't pull that branch.

User@BRD-09-DEC10 /c/path/to/local (master)
$ git pull stage master
[email protected] password:
remote: Counting objects: 1211, done.
remote: Compressing objects: 100% (1191/1191), done.
remote: Total 1211 (delta 81), reused 0 (delta 0)
Receiving objects: 100% (1211/1211), 83.05 MiB | 491 KiB/s, done.
Resolving deltas: 100% (81/81), done.
From ssh://website.com/path/to/repo
 * branch            master     -> FETCH_HEAD
error: Untracked working tree file '.gitignore' would be overwritten by merge.

User@BRD-09-DEC10 /c/path/to/local (master)
$ ls -al
total 5
drwxr-xr-x    4 User Administ        0 Jan  9 11:35 .
drwxr-xr-x   17 User Administ     4096 Jan  9 11:32 ..
drwxr-xr-x    7 User Administ     4096 Jan  9 11:38 .git
-rw-r--r--    1 User Administ       19 Jan  9 11:35 .gitignore
drwxr-xr-x    3 User Administ        0 Jan  9 11:35 nbproject

User@BRD-09-DEC10 /c/path/to/local (master)
$ rm .gitignore

User@BRD-09-DEC10 /c/path/to/local (master)
$ git merge stage/master
fatal: 'stage/master' does not point to a commit

User@BRD-09-DEC10 /c/path/to/local (master)
$ git pull stage master
[email protected]'s password:
From ssh://website.com/path/to/repo
 * branch            master     -> FETCH_HEAD
Already up-to-date.

I was hoping that I get this because the remote branch is already stored locally (it took a while to git the first time), but if that's the case, then I guess I don't know how to merge that branch.

This happens periodically - any idea why?

Upvotes: 0

Views: 1150

Answers (1)

murraybo
murraybo

Reputation: 973

The pull seems to be successfull. Check with

git status

If this is the case

git checkout -- .gitignore 

should bring the file back (the version from remote repository

Upvotes: 1

Related Questions