3

I'm seeing some behavior that my git-fu isn't quite capable of explaining.

The local branch last commit never appears on the remote one it is tracking. Nothing has been committed locally and doing:

$ git diff branch-name origin/branch-name

Comes up empty git pull also says my branch is already up to date.

It seems that git pull has generated a bogus commit (a merge commit), but I can't quite figure out why. This is specially important since we need our app servers to have the same commit hash once git pull is done.

Anything obvious I'm missing out? Any extra info that can help pinpoint what the issue is?

Thank you

Arthur Debert
  • 10,237
  • 5
  • 26
  • 21

1 Answers1

3

What is happening is that you are using git pull which implicitly does a git fetch && git merge origin/master (assuming you were on the master branch). The empty commit is not actually empty. Had you had conflicts, you would have had to resolve them, then add the files and commit. Now the diff will show your conflict resolutions. If a merge has no conflicts, a diff will show you nothing when you are looking at it in gitk, for example.

To avoid this, explicitly do a git fetch and then either merge or rebase your changes with the remote branch (for example origin/master).

You can have pull do a rebase by git pull --rebase. You can also make this the default behaviour for pull if you want by changing the configuration.

hope this helps.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141