git restore
git
इस्तेमाल
git restore [--staged] [-s <commit>] <pathspec>फ़ाइल की सामग्री लौटाने वाला git 2.23 का आदेश; डिफ़ॉल्ट रूप से यह working फ़ाइल को ऊपर लिख देता है और बिना commit बदलाव चले जाते हैं, जबकि --staged सिर्फ़ unstage करता है।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| --staged | unstage the file but keep your edits |
| --worktree | reset the file on disk; this is the default |
| --staged --worktree | both: throw the edits away and unstage |
| -s <commit> | take the content from that commit instead of the index |
| -p | choose hunk by hunk |
उदाहरण
git restore src/app.tswipes uncommitted edits to that file, with no way back
git restore --staged src/app.tstakes it out of the staging area, edits intact
git restore -s HEAD~2 src/app.tsbrings back the version from two commits ago
उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. git restore क्या करता है?
फ़ाइल की सामग्री लौटाने वाला git 2.23 का आदेश; डिफ़ॉल्ट रूप से यह working फ़ाइल को ऊपर लिख देता है और बिना commit बदलाव चले जाते हैं, जबकि --staged सिर्फ़ unstage करता है।
Q. इसे कैसे लिखें?
git restore [--staged] [-s <commit>] <pathspec> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 5 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।
मिलती-जुलती कमांड
man पेज: man git-restore