Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one determine the committer of a cherry-pick in Git?

In Git, cherry-pick retains the original commit's author, timestamp etc, at least when there are no conflicts. But is there any way to determine what user performed the cherry-pick which brought that commit to the new branch?

like image 971
John Lehmann Avatar asked Mar 20 '13 14:03

John Lehmann


People also ask

How can I check my cherry pick status?

In order to cherry-pick changes, you will need to identify your commit hashes. In order to see the commit hashes for your current branch, simply run the “git log” command with the “–oneline” option in order to make it more readable.

What is git cherry pick stackoverflow?

Cherry picking in Git means to choose a commit from one branch and apply it onto another. This is in contrast with other ways such as merge and rebase which normally apply many commits onto another branch. Make sure you are on the branch you want to apply the commit to.

How does cherry pick works in git?

git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick can be useful for undoing changes.


2 Answers

The author will be picked up from the original commit, but the committer (shown with git log --format=full) will be the one doing the cherry picking. This committer field is not secure, as cherry-pick commit creation is ultimately under the control of the cherry-picker. The only reliable way to track the commit creator, in this case the cherry pick instigator, is by signing off on the commit.

A simpler method is to carefully log pushes on the git server. The commits introduced by a push indicate who did the cherry-pick or, more precisely, who published it.

like image 126
user4815162342 Avatar answered Nov 03 '22 22:11

user4815162342


Use either the --pretty=full argument to git log which results in something like:

git log -1 --pretty=full
commit 123abc
Author: Author Name
Commit: Commiter Name
Date: Wed Mar 20 09:43:20

Commmit Message

or, if you are only interested in the name of the commiter --format="%cN" which yields:

git log -1 --format="%cN"
Commiter Name

See git-log(1) for more information.

like image 20
Wesley Wiser Avatar answered Nov 03 '22 21:11

Wesley Wiser