0

I have made a commit in VS2015, but I haven't pushed it yet. Then I made a fetch with Git Extension and I can see, that I'm 2 commits behind the remote branch. But Git Extension doesn't show me my local commit. When I search after the commit hash in Git Extension, he also doesn't find it. Why?

git status also only shows me that I'm two commits behind the remote branch. git log @{u}.. shows nothing on console. git log origin/master..HEAD only shows commits from the old fetched remote.

I wanted to do a rebase, but now I don't know if thats a good idea, if Git Extension can't see my local commit.

testing
  • 19,681
  • 50
  • 236
  • 417

2 Answers2

1

Try to use git reflog to see a history changes in your local repository.

If you can't find your commit there - check that you don't have two copies of the repository in different places.

Ivan
  • 3,084
  • 4
  • 21
  • 22
  • No, it was the same copy. But you were very helpful! If you are interested in the solution, see my answer. – testing Dec 01 '16 at 09:23
0

git reflog shows me:

1d63279 HEAD@{0}: checkout: moving from 9af729af1fbb639a5616528a31e7773f99f564d3 to refactor
9af729a HEAD@{1}: commit: My missing commit
1d63279 HEAD@{2}: checkout: moving from 0e302fee7cbb0ba1306a75e024e324291e3e361f to 1d6327972bd9ac1a585d947e634b69f891a78325
0e302fe HEAD@{3}: checkout: moving from refactor to 0e302fee7cbb0ba1306a75e024e324291e3e361f
1d63279 HEAD@{4}: commit: My old commit

So it seems that I had checked out a special commit in the meantime and worked on that. My solution to this was to make a patch.

// create patch
git format-patch -1 9af729af1fbb639a5616528a31e7773f99f564d3
// show stats
git apply --stat 0001-My-Commit-Message.patch
// check for error before applying
git apply --check 0001-My-Commit-Message.patch
// three-way merge and apply the patch
git am -3 < 0001-My-Commit-Message.patch

Now everything should be OK and I can work further. But I don't know what happens with the old commit.

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417