Git:结帐覆盖的文件 [英] Git: files overwritten by checkout
问题描述
我想结帐一个分支,我收到了这条消息
I want to checkout a branch and I got this message
error: Your local changes to the following files would be overwritten by checkout:
src/main/webapp/data/GuerrillaLabels.json
Please, commit your changes or stash them before you can switch branches.
Aborting
但我希望这些文件被覆盖
But I want those files to be overwritten
推荐答案
git checkout
https://git-scm.com/docs/git-checkout#git-checkout---强制
您可以通过 -f
(强制)标志强制签出分支,这将清除您所做的任何尚未提交的更改.
You can pass the -f
(force) flag to forcefully checkout the branch, this will wipe out any changes you've made that haven't been committed.
git checkout -f branch
如果您不想丢失所有更改,可以专门使用以下命令签出文件:
If you don't want to lose all your changes, you can checkout the file specifically with:
git checkout -- src/main/webapp/data/GuerrillaLabels.json
git 存储
https://git-scm.com/book/en/v1/Git-Tools-Stashing
您还可以隐藏您所做的更改,并在以后重新应用它们
You could also stash the changes that you've made and reapply them later on with
git stash
您可以使用
git stash list
并且您可以使用 pop
应用这些存储.不向 pop
传递任何内容将应用最后一个隐藏的项目.
And you can apply those stashes by using pop
. Passing nothing to pop
would apply the last stashed item.
git stash pop
注意:这种方法可能会导致代码冲突.
这篇关于Git:结帐覆盖的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!