簡體   English   中英

git南瓜與跟蹤分支不同

[英]git squash diverged from tracked branch

我正在嘗試從github存儲庫(以及我的內部gitolite服務器)跟蹤的分支中壓縮某些提交。 我的問題是我正在按http://www.git-scm.com/book/zh-CN/Git-Tools-Rewriting-History#Squashing-Commits中的說明進行遷移,squash已完成,但隨后我的分支與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.

...

現在,我正在使用以下方法進行基准調整:

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,則會丟失提交更改。

有什么幫助嗎?

您正在此處更改git歷史記錄。 您要么需要強制推送(從而覆蓋遠程歷史記錄),要么將您的更改推送到新分支。 我通常在需要重新設置基准時執行后者。

另外,在確定git pull之前,請確保執行git pull

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM