不要忽略 git sourcetree 中的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13826246/
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
Do not ignore files in git sourcetree
提问by Atma
I am downloading an eclipse project from source tree. The .project and .classpath files are not checked in. I want these checked in to do a successful import. I have no gitignore file. Can anyone shed some light as to why these files aren't coming across?
我正在从源树下载一个 eclipse 项目。.project 和 .classpath 文件未签入。我希望这些签入能够成功导入。我没有 gitignore 文件。任何人都可以解释为什么这些文件没有出现?
I also looked on the source machine that checked these files and the files are there. In the sourcetree version on that machine it doesn't show anymore files to be checked in.
我还查看了检查这些文件的源机器,文件就在那里。在该机器上的 sourcetree 版本中,它不再显示要签入的文件。
My exlude file looks like this:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store
This seems like this isn't the case either.
这似乎也不是这种情况。
Thanks!
谢谢!
采纳答案by Adam Dymitruk
you can see what is not committed or staged yet with
您可以看到尚未提交或上演的内容
git status
This should show that those files are not tracked yet. You can start to track them by adding them to the index:
这应该表明尚未跟踪这些文件。您可以通过将它们添加到索引来开始跟踪它们:
git add .project
or add all files (not recommended if you don't have a proper .gitignore defined yet):
或添加所有文件(如果您还没有定义正确的 .gitignore,则不推荐):
git add .
or
或者
git add -A
if you want to stage deletions as well.
如果您还想进行删除。
The other thing that could be happening here is that you are simply not seeing that the .project file is there. OSes usually hide these by default. Use
这里可能发生的另一件事是您根本没有看到 .project 文件在那里。操作系统通常默认隐藏这些。用
ls -A
to include these types of files in the directory listing. To see the contents of what git stored in the last commit, you can also use
将这些类型的文件包含在目录列表中。要查看上次提交中 git 存储的内容,您还可以使用
git ls-tree HEAD
回答by aag
Either your files have not been committed to the repository, as @adam-dymitruk told you, or you are ignoring them. Run this command:
正如@adam-dymitruk 告诉您的那样,您的文件尚未提交到存储库,或者您忽略了它们。运行此命令:
$ git config --get core.excludesfile
$ git config --get core.excludesfile
And have a look at the file you get. You might have some patterns there which exclude your IDE files. I know that PHPStorm asks you at certain point to exclude theirs files globally. It might be that somebody (or eclipse) did the same in your source machine.
看看你得到的文件。您可能有一些排除 IDE 文件的模式。我知道 PHPStorm 会在某些时候要求您在全局范围内排除他们的文件。可能有人(或 eclipse)在你的源机器上做了同样的事情。
回答by Nevik Rehnel
Apart from the repo-local .gitignore
file, there might be further ignore options specified in the file .git/info/exclude
in the repo, or using the config on a global level. You'll probably have to check for these things on the sender's machine, since that's where the files are and don't get checked in.
除了 repo-local.gitignore
文件之外,可能还有.git/info/exclude
在 repo文件中指定的进一步忽略选项,或在全局级别使用配置。您可能需要在发件人的机器上检查这些东西,因为文件就在那里,不会被签入。