2012-07-19 118 views
5

我正在與兩個分支測試Git推不工作

所以,正對主要分支,我所做的:

git merge test 

,一切都很好。所有更改均已合併。

然後將其推到遠程主要,我所做的:

git push 

但似乎像什麼也沒做,它說:

Total 0 (delta 0), reused 0 (delta 0) 
To [email protected]:Company/My-App.git 
b878c9d..0dc7fbe main -> main 

我不認爲它應該如果推送沒有問題,則顯示總計爲零。

如何推我的分支?

+0

你期望什麼? git推動並告訴你。如果你再次推動,它會告訴你「一切都是最新的」。 – 2012-07-19 18:50:59

+0

沒錯,但我並不期望在這裏看到所有的零:Total 0(delta 0),reused 0(delta 0) – Myxtic 2012-07-19 18:53:24

+0

你是否通過github頁面檢查你的回購?只需轉到https://github.com/Company/My-App/commits/main,您是否看到過最後一次提交? – 2012-07-19 18:59:38

回答

3

這只是意味着git不會寫入任何對象。當所有的對象已經在遠程,並且當你合併你只是將標籤'main'移動到最新的提交時,就會發生這種情況。我剛做了一個快速測試,證明:

~/workspace 
    $ git clone [email protected]:korin/test_merge.git 
    Cloning into 'test_merge'... 
    remote: Counting objects: 3, done. 
    remote: Total 3 (delta 0), reused 0 (delta 0) 
    Receiving objects: 100% (3/3), done. 

    ~/workspace 
    $ cd test_merge 
    ~/workspace/test_merge 

    $ git co -b test 
    Switched to a new branch 'test' 

    ~/workspace/test_merge 
    $ echo 'a' > a 

    ~/workspace/test_merge 
    $ git add . 

    ~/workspace/test_merge 
    $ git ci -m 'a' 
    [test 9953350] a 
    1 file changed, 1 insertion(+) 
    create mode 100644 a 

    ~/workspace/test_merge 
    $ git push --set-upstream origin test 
    Counting objects: 4, done. 
    Delta compression using up to 4 threads. 
    Compressing objects: 100% (2/2), done. 
    Writing objects: 100% (3/3), 273 bytes, done. 
    Total 3 (delta 0), reused 0 (delta 0) 
    To [email protected]:korin/test_merge.git 
    * [new branch]  test -> test 
    Branch test set up to track remote branch test from origin. 

    ~/workspace/test_merge 
    $ g co master 
    Switched to branch 'master' 

    ~/workspace/test_merge 
    $ g merge test 
    Updating f5e0184..9953350 
    Fast-forward 
    a | 1 + 
    1 file changed, 1 insertion(+) 
    create mode 100644 a 

    ~/workspace/test_merge 
    $ g push 
    Total 0 (delta 0), reused 0 (delta 0) 
    To [email protected]:korin/test_merge.git 
     f5e0184..9953350 master -> master 
+0

g代表git,它只是一個別名 – 2012-07-19 19:36:40

+0

這很有道理。非常感謝解釋:) – Myxtic 2012-07-19 19:42:29