簡體   English   中英

令人困惑的git消息

[英]Confusing git message

我收到最奇怪的消息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:   folder/test.txt
#       modified:   tesitng.txt
# no changes added to commit (use "git add" and/or "git commit -a")

哪一個? 如果我現在提交,是否如修改后的消息所示將更改添加到存儲庫中,或者是否no changes added to commit

當前沒有任何更改添加到提交。 您會看到工作目錄,臨時區域和git中的最終提交之間的差異。

http://learn.github.com/p/normal.html包含有關使用登台區域的詳細信息,可以很好地說明正在發生的事情。

順便說一句,您的情況是,您有兩個修改過的文件,並且這些更改都沒有上演成為下一次提交的一部分。

更改位於工作目錄中,您必須stage進行更改-將其添加到索引中並對git說可以提交這些文件。 然后,執行提交。

Git已經在告訴您該怎么做:

 (use "git add <file>..." to update what will be committed)

這是git的基礎知識之一,因此我建議您從有關Git基礎知識的教程開始。

git比您以前使用過的其他版本控制系統要復雜一些。 您必須辨別出三種狀態:

  1. 已修改-文件已更改,但不會成為下一次提交的一部分
  2. 暫存-文件已更改,更改將成為下一次提交的一部分
  3. 提交-自上次提交以來文件未更改

您進入第一個狀態,只需更改文件

要從1變到2,請執行git add

要從2變到3,請執行git commit

是的,它在手冊http://learn.github.com/p/normal.html中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM