Git - 不会添加文件? [英] Git - Won't add files?
问题描述
我在Windows上使用GIT,在Aptana Studio中为某些Ruby开发使用GIT。
我已经设法将一些文件上传到GitHub,但之后,一切都停止了。我在我的主目录中有一个新的子文件夹,里面有2个ruby文件。如果我调用git add。,然后是git status,它会一直说工作目录干净,并且没有任何提交。
任何想法都是我可以尝试的吗?
我发现自己和海报的情况类似:
如果我称之为git add。 ,然后是git status,它一直说
工作目录干净并且没有任何提交。
但是我有一个不同于这里的解决方案。从上面的回答以及我在其他地方看到的情况来看,这个问题的常见解决方法如下:1,
- 确保文件上实际保存了更改
- 确保文件没有符合您的排除规则
.gitignore
和.git / info / exclude
- 确保你没有试图添加一个空文件夹。 Git不会跟踪这些。标准解决方案是将名为
.gitkeep
的空白文件作为占位符,以便git将跟踪文件夹。
就我而言,我原本试图在现有的回购库(不知道它在那里)创建一个git回购。前一段时间我从这个子回购库中删除了 .git
文件夹,但我没有意识到它已经太晚了,并且git已经将它作为子模块即可。您可以阅读更多关于这些行为以及如何删除它们的信息此处 ,但是
- 我的解决方案是简单地运行
git rm --cached path_to_submodule
。
I'm having issues where I can't add files to my repository.
I'm using GIT on windows, in Aptana Studio for some Ruby development.
I've managed to push a few files up to GitHub, but then after this, everything's stopped working. I have for example a new sub-folder in my master directory, with 2 ruby files inside. If I call "git add .", and then "git status" and it keeps saying "working directory clean" and has nothing to commit.
I've tried "git add folder/myfile.rb" and still nothing.
Anyone any idea's what I can try?
I found myself in a similar situation as the poster:
If I call "git add .", and then "git status" and it keeps saying "working directory clean" and has nothing to commit.
But I had a different solution than what's here. Since I came to this first, I hope to save others some time.
From the above answers and what I've seen elsewhere, the usual fixes to this problem are:
- Ensure there are actually saved changes on the file in question
- Ensure the file doesn't meet your exclude rules in
.gitignore
and.git/info/exclude
- Ensure you're not trying to add an empty folder. Git won't track those. Standard solution is to place a blank file named
.gitkeep
as a placeholder so git will track the folder.
In my case, I had originally tried to create a git repo around an existing repo (not knowing it was there). I had removed the .git
folder from this sub repo a while ago, but I didn't realize that it was too late, and git was already tracking it as a submodule. You can read more about how these behave and how to remove them here, but
- the solution for me was to simply run
git rm --cached path_to_submodule
.
这篇关于Git - 不会添加文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!