[英]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.