git rebase
git
इस्तेमाल
git rebase [-i] [--onto <base>] <upstream>आपके commit को नई नींव पर फिर से रखता है; hash बदल जाते हैं, इसलिए जिस branch को दूसरे पहले ही खींच चुके हैं उसे rebase न करें — वहाँ merge करें।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| -i | interactive: reorder, squash, reword, drop commits |
| --onto <base> | move the range onto a different base |
| --continue | carry on after fixing a conflict |
| --abort | put the branch back exactly as it was |
| --skip | drop the commit that will not apply |
| --autostash | stash uncommitted work and put it back afterwards |
| --autosquash | apply fixup!/squash! commits automatically |
उदाहरण
git rebase mainreplays your commits on top of main, giving them new hashes
git rebase -i HEAD~3squash or reword the last three commits
git rebase --abortcancel a rebase and return to the original branch
उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. git rebase क्या करता है?
आपके commit को नई नींव पर फिर से रखता है; hash बदल जाते हैं, इसलिए जिस branch को दूसरे पहले ही खींच चुके हैं उसे rebase न करें — वहाँ merge करें।
Q. इसे कैसे लिखें?
git rebase [-i] [--onto <base>] <upstream> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 7 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।
मिलती-जुलती कमांड
man पेज: man git-rebase