简体   繁体   中英

How to identify in bitcuket if commit came from cherry pick or just copy

I have git branch where a developer did cherry pick for one commit. After he pushed the commit, how can I know from bitbucket GUI (Pull request) if this commit came from cherry pick (as I expected) or he just copied the content and created new commit?

When you cherry-pick a commit, unless you take specific steps to change it, the commit message, and author name and datetime will stay the same as the original commit, and the committer name and datetime will be set to the person who cherry-picked it, and the time they did so. If the author and committer are different people, the Bitbucket UI should display both author and committer avatars for the commit, and hovering over each will show the respective author and committer datetime as well. This would be a pretty good indication that the commit was cherry-picked.

When cherry-picking commits from a shared branch, a nice approach is to use the -x option which will add additional text to the commit message showing the commit ID that it was cherry-picked from. I would only bother doing this if you know both commits will eventually end up in the permanent history of the repo.

Note: it's important to realize that you can never know with 100% certainty if a commit was cherry-picked or re-created, because even when creating your own commit, you can specify all inputs to a commit however you please. For example, you could create a new commit and set the author and committer names and datetimes to whatever you'd like, as well as the message, to make it look like you cherry-picked a commit when in fact you didn't. But if the end result is the same it doesn't actually matter. This is because using cherry-pick is merely a convenience so you don't have to do all that extra manual work yourself when creating a new commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM