git rev-parse

git

इस्तेमाल

git rev-parse [--short] <rev>

HEAD या v1.2.0^ जैसे नाम को असली hash में बदलता है और repository कहाँ है यह भी बताता है; script में branch का नाम --abbrev-ref HEAD से मिलता है, और repository के बाहर यह त्रुटि के साथ ख़त्म होता है।

आम विकल्प

विकल्पअर्थ
--short[=<n>]abbreviate the hash
--abbrev-ref HEADprint the current branch name
--show-toplevelprint the root of the working tree
--git-dirprint the path of the .git directory
--is-inside-work-treetrue or false, for scripts
--verify <rev>fail loudly if the name does not resolve

उदाहरण

git rev-parse --short HEAD

the short hash a build should stamp itself with

git rev-parse --abbrev-ref HEAD

the branch name, for a CI script

git rev-parse --show-toplevel

the repository root, wherever you are inside it

उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. git rev-parse क्या करता है?

HEAD या v1.2.0^ जैसे नाम को असली hash में बदलता है और repository कहाँ है यह भी बताता है; script में branch का नाम --abbrev-ref HEAD से मिलता है, और repository के बाहर यह त्रुटि के साथ ख़त्म होता है।

Q. इसे कैसे लिखें?

git rev-parse [--short] <rev> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 6 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।

मिलती-जुलती कमांड

man पेज: man git-rev-parse