我正在尝试从我正在从 github 存储库(以及我的内部 gitolite 服务器)跟踪的分支中压缩一些提交。我的问题是我正在按照http://www.git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits中的解释进行重新定位,壁球已经完成,但是我的分支与 github 不同一个,我无法对其进行更改。
最初我更新了我的分支:
amateo@joshua:~/puppetcode/apache$ git status
On branch squash_test
Your branch is up-to-date with 'github/squash_test'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
nohup.out
spec.log
spec/acceptance/nodesets.kk/
tests/spec_dot.pp
nothing added to commit but untracked files present (use "git add" to track)
这是我的日志:
commit 121881d85b93a0b6b851a33d2cc0321196b90f6d
Author: Angel L. Mateo <myemail>
Date: Tue May 27 11:31:24 2014 +0200
Add apache::dotconf parameters' documentation
commit c51f6b268a8b22e2c84f93d95ee0b98599770269
Author: Angel L. Mateo <myemail>
Date: Tue May 27 11:31:24 2014 +0200
Add apache::dotconf parameters' documentation
commit 82f76d50795eed9839b88745dbabfebe55d8e6bf
Author: Angel L. Mateo <myemail>
Date: Tue May 27 11:29:19 2014 +0200
errata
commit 0c3f836e09bb30dac7a969b9d71176bb2e393a73
Author: Angel L. Mateo <myemail>
Date: Tue May 27 10:58:03 2014 +0200
Add apache::dotconf documentation
commit bce9951f34c04c8dc0e63ae59dc6922ec70866c2
Author: Angel L. Mateo <myemail>
Date: Mon May 26 14:47:14 2014 +0200
A more complete acceptance test.
...
现在,我正在做rebase:
amateo@joshua:~/puppetcode/apache$ git rebase -i -k --no-ff -m HEAD~6
在编辑屏幕中:
pick 9e027da Fix allignment
squash 35cb85e Move template to fixtures directory (as it is only for rspec tests)
squash bce9951 A more complete acceptance test.
squash 0c3f836 Add apache::dotconf documentation
squash 82f76d5 errata
squash c51f6b2 Add apache::dotconf parameters' documentation
squash 121881d Add apache::dotconf parameters' documentation
# Rebase b1ddc75..121881d onto b1ddc75
...
变基完成,我得到:
[detached HEAD 9f1ce65] Fix allignment
4 files changed, 101 insertions(+), 3 deletions(-)
rename {templates => spec/fixtures/templates}/spec.erb (100%)
Successfully rebased and updated refs/heads/squash_test.
但是后来,我的分支已经从上游分道扬镳了,所以我不能推动这些变化:
amateo@joshua:~/puppetcode/apache$ git status
On branch squash_test
Your branch and 'github/squash_test' have diverged,
and have 1 and 11 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
...
然后,如果我运行 git pull,提交更改就会丢失。
有什么帮助吗?