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?
CodePudding user response:
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.