Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Empty Commit With No Changes

Tags:

git

I'm trying to troubleshoot a scenario that pops up, seemingly randomly, every couple of days or so.

I switch to a branch I haven't touched, and am told I am 'ahead' of the remote branch, despite not having made any commits on this branch. I then attempt to figure out what local changes I've made, and find none. In the past, doing a git push seems to resolve the issue, but it makes us extremely nervous to be blindly pushing who-knows-what willy-nilly without understanding the root issue. I've included below a command that I think illustrates my confusion. If I'm ahead of remote, shouldn't the git diff return my changes? I think I'm up-to-date with remote, which is what I'm trying to show with the inclusion of the git fetch/git pull commands.

  $ echo '====FETCH====' && git fetch && echo '====PULL====' && git pull && echo
'====STATUS====' && git status && echo '====DIFF====' && git diff && echo '====
DIFF ORIGIN/DEV====' && git diff origin/dev


====FETCH====
====PULL====
Already up-to-date.
====STATUS====
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean
====DIFF====
====DIFF ORIGIN/DEV====

Does anyone know what's going on here?

like image 255
GWLlosa Avatar asked Aug 03 '15 16:08

GWLlosa


1 Answers

According to me it seems that its an merge commit by git. You can check the logs and check the comment against the commit. You can easily identify if its a merge commit or not.

like image 195
Abhijeet Kamble Avatar answered Oct 05 '22 03:10

Abhijeet Kamble