我正在主分支上更新一些文件,但不是下面列表中的文件,但是每当我运行
git status
时,我都会收到下面的消息,其中文件以红色突出显示,这表明某处可能存在问题,我会如果有人可以解释发生了什么事以及我可以做些什么来解决问题/这些消息,我会很高兴。
它继续出现。
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: repo/source/file1.txt
modified: repo/source/file2.txt
modified: repo/file3.txt
modified: repo/file4.txt
modified: repo/file5.txt
他们是你的
Changes not staged for commit
。这些文件已更改,但您尚未告诉 Git 您要提交它们。 Git 解释了要做什么:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
Git 使用两阶段过程来进行提交。首先,您使用
git add
“暂存”您的更改。这告诉Git“跟踪”文件,在它发生更改时注意它,并且还将其复制到“暂存区域”中,该区域将成为下一次提交。这允许您分段构建提交,并且不必提交您更改的所有内容。
然后
git commit
提交已上演的内容。
您可以使用
git commit -a
提交所有已暂存和未暂存的更改。
git diff
将显示您未暂存的更改。
如果您无意进行这些更改,请使用
git restore
将文件恢复到上次提交时的状态。