我正在尝试git pull
但我得到:
error: Your local changes to the following files would be overwritten by merge: database.sqlite3 Please, commit your changes or stash them before you can merge.
我试过git checkout database.sqlite3
或git stash
甚至 git add -A
但这个文件仍然存在。在 git add -A
这家伙同时坐在暂存文件和未暂存文件上:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: database.sqlite3
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: database.sqlite3
有什么想法吗?
最佳答案
如果您想提交文件,请执行以下操作:
git commit -m 'database.sqlite3 changes'
git add database.sqlite3
git commit -m 'database.sqlite3 more changes'
git push origin [branch-name]
该文件已更改两次,因此需要提交暂存的database.sqlite3
。那么当前未上演的更改需要单独提交。
如果您想删除文件中的更改,请执行以下操作:
git checkout database.sqlite3
git reset
git checkout database.sqlite3
上面重复了 checkout 步骤,因为您需要删除两项更改。为了达到您所处的状态,您可能更改了一个文件,添加了它,然后再次更改了它。这就是为什么您必须撤消两项更改。
在上述任一情况之后,您应该能够执行 git pull。
关于git - 无法 checkout 、 stash 或提交的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30329320/