Kullanım git rebase --interactiveönceki işlemeye çalışma düzenlemek için git reset HEAD~daha sonra, ve git add -psonra biraz daha ekleyin, ardından işlemek yapmak, bazı ekleme ve başka sizin gibi kadar çok kez, işlemek yapmak. İşiniz bittiğinde, çalıştırın git rebase --continueve yığınınızda daha önce bölünmüş olan tüm işlemlere sahip olacaksınız.
Önemli : Etrafınızda oynayabileceğiniz ve istediğiniz tüm değişiklikleri yapabileceğinizi ve eski değişiklikleri kaybetme konusunda endişelenmenize gerek olmadığını unutmayın, çünkü git reflogprojenizde istediğiniz değişiklikleri içeren noktayı bulmak için her zaman koşabilirsiniz (diyelim a8c4ab) ve sonra git reset a8c4ab.
İşte nasıl çalıştığını gösteren bir dizi komut:
mkdir git-test; cd git-test; git init
şimdi bir dosya ekle A
vi A
bu satırı ekle:
one
git commit -am one
ardından bu satırı A'ya ekleyin:
two
git commit -am two
ardından bu satırı A'ya ekleyin:
three
git commit -am three
şimdi A dosyası şuna benzer:
one
two
three
ve git logşuna benziyor (ben kullanıyorumgit log --pretty=oneline --pretty="%h %cn %cr ---- %s"
bfb8e46 Rose Perrone 4 seconds ago ---- three
2b613bc Rose Perrone 14 seconds ago ---- two
9aac58f Rose Perrone 24 seconds ago ---- one
Diyelim ki ikinci taahhüdü bölmek istiyoruz two.
git rebase --interactive HEAD~2
Bu, şuna benzer bir mesaj getirir:
pick 2b613bc two
pick bfb8e46 three
Bu taahhüdü düzenlemek için ilkini pickbir eile değiştirin.
git reset HEAD~
git diff bize ikinci taahhüt için verdiğimiz taahhüdü kaldırdığımızı gösteriyor:
diff --git a/A b/A
index 5626abf..814f4a4 100644
--- a/A
+++ b/A
@@ -1 +1,2 @@
one
+two
Bu değişikliği düzenleyelim ve dosyadaki bu satıra "ve üçüncü" ekleyelim A.
git add .
Bu genellikle etkileşimli bir yeniden pazarlama sırasında çalışacağımız noktadır git rebase --continue, çünkü genellikle daha önceki bir taahhüdü düzenlemek için taahhütlerimize geri dönmek istiyoruz. Fakat bu sefer yeni bir taahhüt oluşturmak istiyoruz. Böylece kaçacağız git commit -am 'two and a third'. Şimdi dosyayı düzenliyoruz Ave satırı ekliyoruz two and two thirds.
git add .
git commit -am 'two and two thirds'
git rebase --continue
Taahhüdümüzle bir çatışmamız var three, bu yüzden çözelim:
Değişeceğiz
one
<<<<<<< HEAD
two and a third
two and two thirds
=======
two
three
>>>>>>> bfb8e46... three
için
one
two and a third
two and two thirds
three
git add .; git rebase --continue
Şimdi git log -pşöyle görünüyor:
commit e59ca35bae8360439823d66d459238779e5b4892
Author: Rose Perrone <roseperrone@fake.com>
Date: Sun Jul 7 13:57:00 2013 -0700
three
diff --git a/A b/A
index 5aef867..dd8fb63 100644
--- a/A
+++ b/A
@@ -1,3 +1,4 @@
one
two and a third
two and two thirds
+three
commit 4a283ba9bf83ef664541b467acdd0bb4d770ab8e
Author: Rose Perrone <roseperrone@fake.com>
Date: Sun Jul 7 14:07:07 2013 -0700
two and two thirds
diff --git a/A b/A
index 575010a..5aef867 100644
--- a/A
+++ b/A
@@ -1,2 +1,3 @@
one
two and a third
+two and two thirds
commit 704d323ca1bc7c45ed8b1714d924adcdc83dfa44
Author: Rose Perrone <roseperrone@fake.com>
Date: Sun Jul 7 14:06:40 2013 -0700
two and a third
diff --git a/A b/A
index 5626abf..575010a 100644
--- a/A
+++ b/A
@@ -1 +1,2 @@
one
+two and a third
commit 9aac58f3893488ec643fecab3c85f5a2f481586f
Author: Rose Perrone <roseperrone@fake.com>
Date: Sun Jul 7 13:56:40 2013 -0700
one
diff --git a/A b/A
new file mode 100644
index 0000000..5626abf
--- /dev/null
+++ b/A
@@ -0,0 +1 @@
+one