0

After doing:

git cherry-pick -n <commit1>
git cherry-pick -n <commit2>
git cherry-pick -n <commit3>
git cherry-pick -n <commit4>

I want to print the list of cherry-picked commits. These commits have not been pushed yet on the current branch as I am using -n option. How to do that?

Please note that I know, SHA1 gets changed after cherry-picking, so the commits should be identified by commit-message IMO.

Community
  • 1
  • 1
Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79
  • 1
    As Vampire said in http://stackoverflow.com/a/41717470/1256452 it's not possible in general. However, `git cherry-pick -n` leaves each message in `.git/MERGE_MSG`. Unfortunately, testing shows that it overwrites this file each time, so you can only get the *last* one anyway. – torek Jan 18 '17 at 18:02

1 Answers1

3

This is not possible. With the -n you tell cherry-pick to not create a commit, but to just apply the changes to the worktree. So now you have the changes of 4 commits in your worktree, but you cannot identify from which commits these changes come, except by examining your command history, in bash this would be history or to only show the cherry-pick commands history | grep cherry-pick.

Vampire
  • 35,631
  • 4
  • 76
  • 102