git 无法将新文件添加到 EGit 中的存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12808656/
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
Can't add new file to repository in EGit
提问by Markus
I'm using EGit with Eclipse Juno. I worked with a local repository and the world was good. Even adding a GitHub repository seemed to be fine. I added it to my local repository under "Remotes", so I can easily push commits to github. But after a while, I noticed that no new files are added to the repository, even if I'm commiting changes. They just are not under version control. They have no symbol, which should mean they are ignored. This is my .ignore
我在 Eclipse Juno 中使用 EGit。我与本地存储库合作,世界很好。即使添加一个 GitHub 存储库似乎也很好。我将它添加到“远程”下的本地存储库中,因此我可以轻松地将提交推送到 github。但是过了一会儿,我注意到没有新文件添加到存储库中,即使我正在提交更改。它们只是不受版本控制。它们没有符号,这意味着它们被忽略了。这是我的 .ignore
.gwt
gwt-unitC
ache
Versandanzeige_Web_proto.war
Versandanzeige_Web.war
war/ajax
war/WEB-INF/classes
war/WEB-INF/deploy
www-test
- The files are in src, so not even close.
- The new files don't appear in the Commit-Dialog, even when checking "show untracked files". They don't appear in the Staging-Window.
- RK -> Team -> "Add to index" doesn't help.
- The files have the same right and are owned by the same user
- They definetly dont show up at github
- 这些文件在 src 中,所以甚至没有关闭。
- 即使选中“显示未跟踪的文件”,新文件也不会出现在提交对话框中。它们不会出现在暂存窗口中。
- RK -> 团队 -> “添加到索引”没有帮助。
- 文件具有相同的权限并归同一个用户所有
- 他们绝对不会出现在 github 上
Any ideas how to fix that? Any additional information needed?
任何想法如何解决这个问题?需要任何其他信息吗?
Update: There are no errors in the error log.
更新:错误日志中没有错误。
I do have (HEAD) next to my newest branch.
我的最新分支旁边确实有(HEAD)。
More details:
I got my trunk T, beginning at T0. At T1, there is a branch A, which has changes to T1.
At T2, there is another branch, B. It has no changes to T2.
The strange thing: it is not indicated in History view. The master branch is also missing.
I can still switch to them. When I do git reflog
, there are no entries before or including T2, just everything afterwards.
I removed the branches without commits:
更多细节:
我得到了我的行李箱 T,从 T0 开始。在 T1,有一个分支 A,它对 T1 进行了更改。在 T2,还有另一个分支 B。它对 T2 没有变化。奇怪的是:它没有在历史视图中显示。主分支也不见了。我仍然可以切换到它们。当我这样做时git reflog
,在 T2 之前或包括 T2 之前没有条目,只有之后的所有条目。
我删除了没有提交的分支:
The new files are still shown as ignored:
新文件仍显示为忽略:
Output from command line:
命令行输出:
$ git branch -a:
* master
maven
$ git status
# On branch master nothing to commit (working directory clean)
About the detached HEAD proposel: I didn't do what is described in the article, checking out an old state and work from that. And I can't see any undone commits.
关于分离的 HEAD 提议:我没有做文章中描述的事情,检查旧状态并从中工作。而且我看不到任何未完成的提交。
Sorry for my bad english, I didn't use it for a while. Please ask for clarification, if I write something hard to understand.
抱歉我的英语不好,我有一段时间没有使用它。如果我写的东西难以理解,请要求澄清。
Update: I could add a file in another folder (/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar).
更新:我可以在另一个文件夹(/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar)中添加一个文件。
回答by Markus
Alright, I found the error. For some reason I don't really know, there was another .gitignore file ABOVE my Project folder (in repository folder), where my COMPLETE project folder was included. I really don't know how that happened. Of course, this file didn't show up in Eclipse. I tried to add the files on the command line, but gut the error message "File is in .gitignore file". After deleting that file, it worked find. Sorry for the trouble.
好的,我发现了错误。出于某种原因,我真的不知道,在我的项目文件夹(在存储库文件夹中)上方还有另一个 .gitignore 文件,其中包含我的完整项目文件夹。我真的不知道那是怎么发生的。当然,这个文件没有出现在 Eclipse 中。我尝试在命令行上添加文件,但显示错误消息“文件在 .gitignore 文件中”。删除该文件后,它可以找到。抱歉,添麻烦了。
回答by Bahadir Tasdemir
Sometimes EGit does not work properly and add to index does not work. In that kind of situations you can go to the root folder of your project (where .git folder is placed) with a file explorer, right click on an empty area inside the folder, select "git bash". This will open the git console for you. Now type "git add path_to_file". This will add the file to the git system for indexing. Now go and refresh your project in eclipse and you will see it is added to the index. This can be used wile resolving conflicts inside eclipse because adding to the index indicates "mark as merged" to the git system by re-adding the merged file.
有时 EGit 不能正常工作并且添加到索引也不起作用。在这种情况下,您可以使用文件资源管理器转到项目的根文件夹(.git 文件夹所在的位置),右键单击文件夹内的空白区域,选择“git bash”。这将为您打开 git 控制台。现在输入“git add path_to_file”。这会将文件添加到 git 系统以进行索引。现在在 eclipse 中刷新你的项目,你会看到它被添加到索引中。这可以用于解决 eclipse 内部的冲突,因为通过重新添加合并的文件,添加到索引表明“标记为合并”到 git 系统。
Also sometimes the "Remove from index" does not work in eclipse, you can do the same thing in that kind of situation: this time write "git remove --cached -f path_to_file". Here do not forget to add "--cached" because otherwise your file will be deleted. -f stands for "force" to force the command. For any folder (directory) to remove from index type "git remove --cached -r -f path_to_folder".
另外有时“从索引中删除”在 eclipse 中不起作用,你可以在这种情况下做同样的事情:这次写“git remove --cached -f path_to_file”。这里不要忘记添加“--cached”,否则您的文件将被删除。-f 代表“强制”强制执行命令。对于要从索引中删除的任何文件夹(目录),请键入“git remove --cached -r -f path_to_folder”。