繁体   English   中英

git需要将文件重新添加到每个提交中

[英]git needs to re-add files to every commit

嗨,我刚刚开始我的git repo,这是我第一次在Windows中使用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:   bonfire/content.php
#       modified:   bonfire/style_1.css
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .htaccess
#       .htaccess_del
#       .smileys/
#       1.htaccess
#       docs/
#       nbproject/
no changes added to commit (use "git add" and/or "git commit -a")


$ git add bonfire/content.php

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   bonfire/content.php
#
# 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:   bonfire/style_1.css
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .htaccess
#       .htaccess_del
#       .smileys/
#       1.htaccess
#       docs/
#       nbproject/

我真的不想一直这样做。 我相信我正确地添加了该项目。 完全不知道该怎么办

谢谢

这就是git的工作方式,您的存储库已正确设置。 您提交暂存区域而不是工作树的内容,因此必须首先将更改添加到暂存区域。 如果您只想提交一些更改,或将更改分为几个提交,这非常方便,因为您甚至可以将部分文件更改添加到暂存区(使用git add -p )。

但是,如果您只想提交所有修改过的文件,则有一个捷径:只需使用git commit -a 这将直接在工作树中提交所有修改和删除的文件。 您仍然必须手动添加新创建的文件,但这听起来还是您所期望的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM