एडवांस्ड Git
Amanda Crawford-Adamo
Software and Data Engineer
Git Rebase Command:
git rebase <branch_name>

data-cleanup फीचर ब्रांच checkout करें.git checkout data-cleanup
main ब्रांच को data-cleanup पर rebase करें.git rebase main
data-cleanup के commits, main के नवीनतम commit के बाद दोबारा बनाए जाते हैंdata-cleanup commits के नए hashes बनते हैंNote: यदि कोई conflicts हों, तो उन्हें मैन्युअली resolve करना होगा.

git rebase -i <commit_hash>
Functionality
Warning!
main जैसी public branches पर rebase न करें$$
यहाँ commit history एडिट करने से पहले का data-validation ब्रांच history है.
$ git log --oneline data-validation
abc1234 Optimize validation performance
def5678 Fix validation bug
ghi9101 Add data validation function
xyz1234 New Main Branch Commit
vwx7890 Main Branch Commit
jkl2345 Initial commit
खुले editor में pick और fixup कमांड्स से commit history ऐसे एडिट करते हैं.
$ git rebase -i HEAD~3
pick ghi9101 Add data validation function
fixup def5678 Fix validation bug
fixup abc1234 Optimize validation performance
# Rebase xyz1234..abc1234 onto HEAD~3(xyz1234) (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# f, fixup <commit> = like "squash", but discard this commit's log message
...
Before
$ git log --oneline data-validation
abc1234 Optimize validation performance
def5678 Fix validation bug
ghi9101 Add data validation function
xyz1234 New Main Branch Commit
vwx7890 Main Branch Commit
jkl2345 Initial commit
After
$ git log --oneline data-validatoin
mno6789 Add data validation function
xyz1234 New Main Branch Commit
vwx7890 Main Branch Commit
jkl2345 Initial commit
निम्न commits एक में combine हो गए हैं

Merge
Rebase
Merge
पूरी हुई फीचर्स इंटीग्रेट करने और development context सुरक्षित रखने के लिए
Rebase
फीचर ब्रांचेज़ को main से अपडेट रखने या merge से पहले cleanup के लिए
Remember
एडवांस्ड Git