Git - 错误:未经跟踪的工作树文件将被合并覆盖。中止

时间:2016-03-21 23:45:26

标签: git

我是git的新手并且离开了使用实时服务器。

在几次成功git pull次操作后,在最新的操作中,我收到了此错误:

error: Untracked working tree file 
'www/files/userphotos/styles/100x100/noavatar.png' would be overwritten by merge.  Aborting

我尝试了git stash,但没有任何反应 - git pull上的错误仍然存​​在。

如何执行git pull而不会弄乱服务器上的任何内容?

1 个答案:

答案 0 :(得分:2)

你需要在git stash之前进行git add

# Add the file to the staging area
git add . -A (alias for git add . && git add -u .)

# stash changes
git stash

# opull server updates
git pull

<强> Use git worktree

git worktree 允许您同时在不同的分支机构工作, 在这里你可以看到一个文件夹是&#34;脏&#34;而第二个不是

他们都使用相同的(单个)存储库

enter image description here

如果您稍后使用rebase:

  • 注意:(Since Git 2.7
    您也可以使用git rebase [--no]-autostash