I find myself doing this a lot when cherry-picking a commit from another branch.
$ git log -1 another_branch commit <commit_sha> // copy <commit_sha> $ git cherry-pick <commit_sha>
Can I do all of this in one command, if so, what is it?
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.
Cherry-picking in TortoiseGit is invoked from the Revision Log Dialog. Within this dialog, select the commit(s) to cherry-pick, then right-click on one of the selected commits to pop up the context menu. Select Cherry Pick this commit... (or Cherry Pick select commits... if more than one commit is selected).
Just go with:
$ git cherry-pick another_branch
This will cherry-pick the last commit from another_branch.
Branches in git are just references to the last commit in that branch, you can use them instead of commit SHAs in your commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With