簡體   English   中英

Git:添加不暫存文件

[英]Git: add not staging files

我對文件進行了更改。 在嘗試使用git add文件后(像往常一樣),我繼續提交git commit -m 但是,終端向我吐出這個:

no changes added to commit (use "git add" and/or "git commit -a")

我檢查了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:   ../../Round 1/R1C3/R1C3.py

在對管子進行了一些搜索之后,我發現我可以通過其他各種方式暫存文件,但不能使用沒有標志的git add 我可以使用git add -Agit add -u或使用交互式登台進行登台。

困惑並且不真正理解為什么我的 reg git add不起作用,我偽造了使用git add -A 故事變得很奇怪。 在我的機器上重新啟動后(2011 Macbook Air running Mavericks)我在同一個文件上嘗試了一些好的 ol' git add ......你猜怎么着? 有效。 所以我繼續說。

現在,不久之后,我又遇到了同樣的問題。 git add將不起作用(同一目錄)。

有誰知道我做錯了什么? 由於上述替代方案,這並不是一個真正的大問題,但我想了解為什么會發生這種情況。 特別是因為這在過去一直對我有用,而今天,它壞了:(

**注意:我計算機上的其他版本控制項目似乎沒有受到影響。

git add R1C3.py
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:   ../../Round 1/R1C3/R1C3.py
# no changes added to commit (use "git add" and/or "git commit -a")

git add -A
git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   ../../Round 1/R1C3/R1C3.py
#

當您執行git add時,它應該與文件在同一目錄中運行或傳遞文件的相對路徑。 由於該文件位於父目錄中,因此git add將找不到該文件。 在您的情況下,您應該cd ../../Round 1/R1C3/然后運行git add R1C3.py

git add -A之所以有效,是因為它會暫存存儲庫中的所有文件,而不管您在目錄中的位置。

暫無
暫無

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

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