git提交远程存储库无法正常工作

时间:2012-03-22 16:46:01

标签: git commit

不明白为什么我对远程git repo的提交无效。

所以我从远程仓库克隆一个分支

git clone -b MYBRANCH git@172.27.1.111:/home/my.git

我修改了一个名为test

的文件
git diff shows the change

diff --git a/test b/test
index e69de29..9ccc327 100644
--- a/test
+++ b/test
@@ -0,0 +1,3 @@
+changed.
+
+

当我去提交时,没有对提交添加任何更改。

git commit -m "changed the test file"
# On branch MCKINLEY
# 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:   test
#
no changes added to commit (use "git add" and/or "git commit -a")

我在这里缺少什么?

3 个答案:

答案 0 :(得分:3)

您需要将其添加到索引中。

git add test

猜猜你可能是git的新手..请查看here,了解索引的简介。

答案 1 :(得分:2)

是不是消息告诉你该怎么做?

执行git add test

请注意,git add不仅可以添加新文件,还可以添加/暂存对现有文件的修改

答案 2 :(得分:1)

我建议尝试使用git状态来查看是否需要添加该文件。

git status

如果你仍然需要在提交中添加文件,那么要么执行git add。或者git add

git add .

然后你的提交应该准备好了

git commit -a

希望有所帮助!

相关问题