Search code examples
gitsha1cherry-pick

Git cherry-pick and sha-1 value


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


Solution

  • 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?