无法变基:您有未暂存的更改 git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5128076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cannot rebase: you have unstaged changes git
提问by dagda1
I am on a branch named new_nlp and when I do a git status, I get the following:
我在一个名为 new_nlp 的分支上,当我执行 git status 时,我得到以下信息:
# On branch new_nlp
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: untitled.
I cannot see this file untitled as it is deleted.
我看不到这个文件无标题,因为它被删除了。
I want to switch to master and perform a rebase from new_nlp but when I checkout master and issue the command:
我想切换到 master 并从 new_nlp 执行 rebase 但是当我结帐 master 并发出命令时:
git rebase new_nlp
I get the following error message:
我收到以下错误消息:
cannot rebase: you have unstaged changes
D untitled.
I cannot see this file and I have no idea how to delete it. I have no idea how it got added.
我看不到这个文件,也不知道如何删除它。我不知道它是如何添加的。
Does anyone know how I can get past this road block. I have no idea why the file remains in the index.
有谁知道我怎样才能通过这个路障。我不知道为什么该文件保留在索引中。
回答by knittl
the file is deleted and is already tracked by git. you can:
该文件已被删除并且已被 git 跟踪。你可以:
- delete the file and commit the change (
git rm --cached untitled; git commit
) or - run
git checkout -- untitled
to get back the file
- 删除文件并提交更改 (
git rm --cached untitled; git commit
) 或 - 运行
git checkout -- untitled
以取回文件
回答by Simon
Remove it from the index using git rm untitled.
使用 git rm untitled.