我有一个需要更新的存储库。
然而,拉动会导致错误:
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 status:
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 :(得分:2)
首先按Stash
或Commit
清理工作树。如果你处于任何变化的中间,我更喜欢藏匿。
$ git add .
$ git stash save 'message'
拉远程分支更改。
$ git pull origin <branch-name>
从Stash中检索更改。
$ git stash apply
如果发生冲突,请解决冲突。
$ git status # find the conflicted file(s) -> red color files normally
# resolve conflicts
添加,提交,推送到远程。
$ git add .
$ git commit -m 'message'
$ git push origin HEAD
如果所有东西都完美无缺,那么请清理藏匿处。 [可选]
$ git stash drop
答案 1 :(得分:0)
存储您的更改,下拉代码,解除更改,提交,推送,繁荣。完成。
或
在控制台中只需输入git pull --ff-only。这将快速转发分支的本地副本,使其与遥控器相同。