2015-10-15 51 views
1

我有這個分支:Git會詢問我拉,每次我要推到我自己的分支

地方:

bugfix/VMS-172-back-arrow-on-activity-bar 

遠程:

origin/bugfix/VMS-172-back-arrow-on-activity-bar 

所以我添加本地我的變化然後推它。

然後我再次在本地做了一些改動,我推了它(我在提交時使用git commit --amend)。但是這次git讓我在推之前拉。爲什麼?

我的git的日誌:

commit f38a4d8828a2fadec3c62c08cc1c90ea66a719bd 
Merge: 172968f 642178d 
Author: degensharew <[email protected]> 
Date: Thu Oct 15 09:45:59 2015 +0300 

    Merge branch 'bugfix/VMS-172-back-arrow-on-activity-bar' 
    of myrepository into bugfix/VMS-172-back-arrow-on-activity-bar 

    Conflicts: 
     vms-mobile/app/src/main/java/AbstractActivity.java 

commit 172968f6dcf533e43749986eba95a008c585bbb1 
Author: degensharew <[email protected]> 
Date: Wed Oct 14 17:21:01 2015 +0300 

    Fixed bug VMS-172. 
    Avoided rounded corner style from search view. 
    Style back arrow and title of action bar view. 
    Disabled 'back action' from activity title. 

commit 642178d27bccbe9ea48c7d8ae123f1c8c01f921f 
Author: degensharew <[email protected]> 
Date: Wed Oct 14 17:21:01 2015 +0300 

    Fixed bug VMS-172. 
    Avoided rounded corner style from search view. 
    Style back arrow and title of action bar view. 
    Disabled 'back action' from activity title. 

NB:我是唯一一個在這個分支上工作。

回答

2

我在提交時使用了git commit --amend)。但是這次git要求我在推送前拉。爲什麼?

當您使用git commit --amend時,您重寫了本地分支中HEAD提交的歷史記錄。這意味着在這一點上,您的本地和遠程分支機構彼此分離。

前提交修改:

remote: A <- B <- C 
local: A <- B <- C 

提交修改後:

remote: A <- B <- C 
local: A <- B <- C'  (the apostrophe indicates a new commit) 

不能快進,因爲你的本地分支遠程分支已經從遠程分歧。實際上,你的最新提交位於不同於遠程的基礎之上,Git拒絕自動應用此提交。這裏的兩種解決方案將是合併當地的分支機構到遠程,或衍合遙控器上當地的分支,然後將其推入。

至於爲什麼你被迫再次,這個拉可能是由於許多原因。例如,如果你做了另一個提交修改,這可以解釋它。一位同事向同一個分支承諾也可以解釋它,但不是你的情況,因爲你說你是唯一一個在這個分支工作的人。

+0

謝謝,乾淨的答案。 – dsharew

相關問題