0

I am out of ideas about what might be wrong here. I have this one repository that won't pull or merge anymore. git status tells me I am one behind and it can be fast-forwarded, but neither pull nor merge do anything. I've checked a lot of other questions, but they had solutions that don't apply here.

xxx@yyy MINGW64 //filesystem/directory (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

xxx@yyy MINGW64 //filesystem/directory (master)
$ git merge origin/master
Updating 4f3a29c..dbe3611

xxx@yyy MINGW64 //filesystem/directory (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

xxx@yyy MINGW64 //filesystem/directory (master)
$ git pull
Updating 4f3a29c..dbe3611

xxx@yyy MINGW64 //filesystem/directory (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

xxx@yyy MINGW64 //filesystem/directory (master)
$ git branch -vv
* master 4f3a29c [origin/master: behind 1] last commit message

xxx@yyy MINGW64 //filesystem/directory (master)
$ git merge origin/master
Updating 4f3a29c..dbe3611

xxx@yyy MINGW64 //filesystem/directory (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

Is there something obvious I'm missing? Is my repo corrupt? v2.10.2 was giving me the problem, updated to v2.11 and it still happens. Thanks for any help!

Edit 1: Output from git branch -a

$ git branch -a
* master
  remotes/origin/master

Edit 2: reset, as suggested by @Vampire

git reset --hard origin/branch was the first command to give me:

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

it had not occurred to me to check for the lock file, but there it was. I deleted it, and the pull worked. I don't know why pull and merge didn't give me that hint. Thanks for your help!

atheaos
  • 721
  • 2
  • 7
  • 16
  • This is rather odd, as the `git merge` shows that it's done, but the second and third `git merge`s repeat it as if it's not done, then show that it's done. I have several suspicions; can you add the output from `git branch -a`? [edit] Well, so much for the first suspicion (that there was a branch with a name like `MASTER` causing problems)! – torek Mar 20 '17 at 15:54
  • Next idea: look at `.git/refs/heads` (directory, should have one file named `master`) and `.git/packed-refs` (file). See if/how they change after `git merge origin/master`. See if the file `.git/refs/heads/master` changes contents (it should but it seems like it is not doing so), or is created if it did not exist before. – torek Mar 20 '17 at 16:00
  • @torek the files are not being updated, as expected. I checked the permissions and they match other repos on the same server that do work. – atheaos Mar 20 '17 at 16:09
  • Interesting. I'm now out of my depth because I do not use Windows, but I wonder if there is some sort of mandatory file lock or ACL issue or similar. – torek Mar 20 '17 at 16:14
  • Re edit 2: looks like there's a bug in the lock detect/complain code: it correctly complained for `git reset --hard` but not for `git merge`. – torek Mar 20 '17 at 16:59

3 Answers3

2

I have no idea why it behaves like that, but you could just repoint your local branch at the remote commit with git reset --hard origin/master, as the update is a fast-forward anyway.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I'll be somewhat surprised if this works. I suspect that somehow the `.git/refs/heads/master` file is not being created or not being updated, perhaps due to some Windows quirk. – torek Mar 20 '17 at 16:02
  • @torek yeah, could be. We will see. If it didn't work, I'll delete my answer. :-) – Vampire Mar 20 '17 at 16:04
  • 1
    @Vampire, well the reset didn't fix it, but it led me to the lock file, which did (see Edit 2). I'll go ahead and accept this so that someone in the future might follow the same path. – atheaos Mar 20 '17 at 16:17
0
git pull origin master

This should get your local branch up to date with master and highlight any conflicts.

Yack
  • 51
  • 5
  • This is actually what I tried first, but http://stackoverflow.com/a/18924297/784868 seemed to indicate that it wasn't necessary, so I started using `git pull`. I retried it just to verify, and the same thing occurs (nothing). – atheaos Mar 20 '17 at 15:34
  • @altheaos you are right, it is exactly the same, as `origin/master` is the upstream branch for your local branch. – Vampire Mar 20 '17 at 15:56
0

Do you want to merge your current branch into the master?

In that case you need to do the following

git checkout origin/master

git merge "Whatever your current branch name is".

kkflf
  • 2,435
  • 3
  • 26
  • 42
  • My branch was originally checked out from origin/master, and has been in use for sometime. I used `git branch -vv` to verify that it was still tracking. – atheaos Mar 20 '17 at 15:37
  • I just read your log once again. I misunderstood what you were trying since you tried to merge. @Yack got what looks like the correct answer – kkflf Mar 20 '17 at 15:37