0

I have created a Master branch like this:

git branch -u MyMasterBranch origin/MyMasterBranch

and I have created other branches from that like this:

git checkout MyMasterBranch
git checkout -b myJIRAbranch-1

and have worked on those smaller myJIRAbranch-1 branches and have merged them at the end to the MyMasterBranch with git merge --squashmyJIRAbranch-1

Now I want to find the git commit numbers for those merges that I have done from my JIRA branches into my MyMasterBranch ?

What's a good command to do that? that gives me a clean and nice report?

2 Answers2

2

As Chronial noted, the information about individual commits is not retrievable directly, unless you supplied the --log switch when saying git merge --squash. In the latter case, you might see SHA1 hashes of the individual commits in the squashed commit messages, and should be able to retrieve the commits using these hashes.

If not, we may consider the original branches lost. A few questions on this site already address this problem:

To sum up, git reflog and git log -g are your friends. All solutions presume that you still have access to your development repository (where the individual commits are located) and that the commits are not "too old" (otherwise git gc might have cleaned them irrevocably).

Community
  • 1
  • 1
krlmlr
  • 25,056
  • 14
  • 120
  • 217
1

I don’t think that is possible. You told git to lie about the merges, and that it did. Git does not store any information about merging if you use --squash.

Finding you merge commits is basically impossible now. You could write a script that does some guessing – get every diff in master and try to find the same changes in jira. That will obviously not produce reliable results, but is the best I can think of. There is no built-in git command to do that.

Chronial
  • 66,706
  • 14
  • 93
  • 99
  • Are you sure? I used SourceTree GUI tool and it is kind of showing me the git commit numbers.,,, didn't spend much time on it yet but at a quick look that's what I noticed –  Jul 16 '13 at 22:38
  • I assume “git commit numbers” means SHAs? And what is “kind of showing”? I assume you are talking about the fact that SourceTree is showing you the SHA of the commit you are currently looking at, which does not help you at all here. If there is only one parent commit, git does not know about a merge. – Chronial Jul 16 '13 at 22:55