Created
January 15, 2013 15:44
-
-
Save ebouchut/4539565 to your computer and use it in GitHub Desktop.
git SHA1 to reference name conversion (back and forth)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rev-parse: RefName ======> SHA1 | |
git name-rev: SHA1 <===== RefName | |
# Convert the reference name HEAD to its corresponding SHA1 | |
git rev-parse HEAD # Assuming for the sake of example that it outputs 1234567 | |
# Convert the SHA1 (1234567) into its reference name (should output HEAD in our example) | |
git name-rev 1234567 | |
# or else | |
git describe --all --contains 1234567 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ouput the name of the current branch:
git name-rev --name-only $(git rev-parse HEAD)