我做了一个git commit -m "message",像这样:

> git commit -m "save arezzo files"
# On branch master
# 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:   arezzo.txt
#       modified:   arezzo.jsp
#
no changes added to commit (use "git add" and/or "git commit -a")

但是之后,当我做git状态时,它显示了相同的修改文件:

> git status
# On branch master
# 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:   arezzo.txt
#       modified:   arezzo.jsp
#
no changes added to commit (use "git add" and/or "git commit -a")

我做错了什么?


当前回答

如果你有更多的文件,在我的例子中,我有7000个图像文件,当我试图从项目的路由文件夹中添加它们时,它还没有添加它们,但当我进入图像文件夹时,一切正常。通过目标文件夹和命令,像俯视图

git add .
git commit -am "image uploading"
git push origin master

git push origin master枚举对象:6574,完成。计数对象:100%(6574/6574),完成。Delta压缩使用高达4 线程压缩对象:100%(6347/6347),完成。写作对象: 28% (1850/6569), 142.17 MiB | 414.00 KiB/s

其他回答

我有一个问题,我在做提交-修改后,甚至发布了一个git添加。但它还是不能工作。原来我做了一些.vimrc自定义,我的编辑器不能正常工作。修复这些错误以使vim返回正确的代码就解决了这个问题。

您没有添加更改。或者专门添加它们通过

git add filename1 filename2

或者添加所有更改(从项目的根路径)

git add .

或者在承诺时使用简写“-a”:

git commit -a -m "message".

如果你有更多的文件,在我的例子中,我有7000个图像文件,当我试图从项目的路由文件夹中添加它们时,它还没有添加它们,但当我进入图像文件夹时,一切正常。通过目标文件夹和命令,像俯视图

git add .
git commit -am "image uploading"
git push origin master

git push origin master枚举对象:6574,完成。计数对象:100%(6574/6574),完成。Delta压缩使用高达4 线程压缩对象:100%(6347/6347),完成。写作对象: 28% (1850/6569), 142.17 MiB | 414.00 KiB/s

发生这种情况的原因是,在Git跟踪的另一个文件夹中有一个已经被Git跟踪的文件夹。例如,我有一个项目,我给它添加了一个子文件夹。在我将其中一个放入另一个之前,Git已经跟踪了它们。为了停止跟踪里面的文件,找到它并删除Git文件:

rm -rf .git

在我的例子中,我有一个WordPress应用程序,我在里面添加的文件夹是一个主题。所以我必须转到主题根目录,删除Git文件,这样整个项目就会被父级WordPress应用程序跟踪。

你可以这样做:

git add -u -n

要检查哪些文件已修改并将被添加(预演:-n选项),然后

git add -u

添加修改过的文件