2017-04-22 77 views
1

我有一個需要更新的倉庫。git拉和推拒絕,沒有任何工作了

但是拉將導致一個錯誤:

error: The following untracked working tree files would be overwritten by merge: 

其實我希望他們能夠被覆蓋......

如果我試圖把我也得到一個錯誤

hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. 

如何我能解決這個問題嗎?

編輯: git的狀態:

On branch master 
Your branch and 'origin/master' have diverged, 
and have 1 and 4 different commits each, respectively. 
    (use "git pull" to merge the remote branch into yours) 
nothing to commit, working tree clean 
+0

您必須重置或修改你上次提交 – sinsuren

+0

如果你真的希望他們被覆蓋,你可以嘗試'混帳拉起源--force' – sinsuren

+0

這是什麼混帳'顯示status'你? –

回答

0

藏匿更改,拉下代碼,unstash變化,提交,推,繁榮。完成。

只需在您的控制檯中鍵入git pull --ff-only。

這將快速轉發您的本地分支副本,因此它與遠程相同。

2
  1. 首先清理你的工作樹StashCommit。如果你處於任何變化的中間,我寧願隱藏。

    $ git add . 
    $ git stash save 'message' 
    
  2. 拉遠程分支變化。

    $ git pull origin <branch-name> 
    
  3. 檢索Stash中的更改。

    $ git stash apply 
    
  4. 解決衝突(如果發生)。

    $ git status   # find the conflicted file(s) -> red color files normally 
    # resolve conflicts 
    
  5. 添加,提交,推送到遠程。

    $ git add . 
    $ git commit -m 'message' 
    $ git push origin HEAD 
    
  6. 如果所有的東西都變得完美然後清理存儲。 [可選]

    $ git stash drop 
    
+0

@Matthias Pospiech,它是否適合你或任何其他錯誤? –