Reputation: 6119
In https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project is example that shows how to cherry pick on a branch. In this example the sha-1 value of commit is used in full length?
$ git cherry-pick e43a6fd3e94888d76779ad79fb568ed180e5fcdf
Doesn't the cherry-pick allow short sha-1 values like e43a6, so that the following is valid?
$ git cherry-pick e43a6
Upvotes: 1
Views: 4825
Reputation: 1906
Yes, but the provided SHA snippet has to identify unique refspec. Take a look here: How much of a git sha is *generally* considered necessary to uniquely identify a change in a given codebase?
Upvotes: 3
Reputation: 301037
Yes, you can use the short value anywhere you can use the long hash. Not sure about the intent behind the doc using the full hash, but git cherry-pick e43a6
works too.
Guideline on short hash:
The full SHA-1 object name (40-byte hexadecimal string), or a leading substring that is unique within the repository. E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both name the same commit object if there is no other object in your repository whose object name starts with dae86e.
https://git-scm.com/docs/gitrevisions
Bonus:
Default short hash is 7 character in length:
git rev-parse --short e43a6fd3e94888d76779ad79fb568ed180e5fcdf
e43a6fd
Upvotes: 3