简体   繁体   中英

git needs to re-add files to every commit

Hi I have just started my git repo and this is my first time using git in windows

anyway I have added my project and commited it, however, whenever I mod a file it thinks that I need to re-add even though I have already done that.

$ 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/

I really don't want to have keep doing this. I believe I added the project properly. Not sure what to do at all

Thanks

This is just how git works, your repository is set up correctly. You commit the contents of the staging area , not your working tree, so you have to add the changes to the staging area first. This is quite handy if you only want to commit some of your changes, or split your changes into several commits, because you can even add partial file changes to the staging area (using git add -p ).

However, in case you just want to commit all the modified files, there is a shortcut: Just use git commit -a . This will directly commit all modified and deleted files in working tree. You will still have to add newly created files manually, but it sounds like that's what you expect anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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