Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何提交文件(如果在添加和提交文件后对其进行了修改)_Git - Fatal编程技术网

Git 如何提交文件(如果在添加和提交文件后对其进行了修改)

Git 如何提交文件(如果在添加和提交文件后对其进行了修改),git,Git,我有一个问题,我git add today.c然后我git commit today.c,通过这个步骤,文件today.c已经被修改(我使用一个shell脚本来做这个修改),然后我将文件推送到原始主文件,但是文件仍然是一样的,它没有被修改,而是在我的工作目录中,今天.c确实被修改了 如何将修改后的文件推送到原始主机?四光,请执行以下操作? git add today.c git提交-m'modify' git推送原始主机 然后再次检查。如果您在文件中提交了更改,然后将更改推送到另一个分支,则在您

我有一个问题,我
git add today.c
然后我
git commit today.c
,通过这个步骤,文件
today.c
已经被修改(我使用一个shell脚本来做这个修改),然后我将文件推送到
原始主文件
,但是文件仍然是一样的,它没有被修改,而是在我的工作目录中,
今天.c
确实被修改了


如何将修改后的文件推送到
原始主机

四光,请执行以下操作?
git add today.c

git提交-m'modify'

git推送原始主机


然后再次检查。

如果您在文件中提交了更改,然后将更改推送到另一个分支,则在您的情况下,仅将提交推送到该分支,即推送到
源代码

您在提交后更改了文件,因此在工作副本中对其进行了修改,但尚未在存储库中注册为提交。这就是为什么推送不会更改远程存储库中的文件。
为此,必须再次提交文件,然后推送新的提交

请参阅本说明集:

git add today.c
git commit -m "First change" # Creates commit 1
./your_magical_shell_script_changes_today.c
git push origin master # Only commit 1 exists, therefore, only this is pushed to master
git add today.c
git commit -m "Changed by the shell script" # Here, the commit 2 is created
git push origin master # Now it is pushed to origin, too.

非常感谢,但我不想再做“git add,commit,push”,如果在这种情况下,我不需要在“git commit”步骤中更改文件,我可以先修改文件,然后再“add,commit,push”它。但是现在我想要的是如何更新文件并推送它。我尝试了很多方法,但是都失败了,我想我应该在“git add”步骤中修改文件,但是如何修改呢?很抱歉,你不想做“git add,commit,push”,但是你必须这样做。这就是Git的工作原理。如果要跳过添加步骤,可以使用
git commit-am“Second commit”
直接提交。推送是必需的,尽管非常感谢,但我不想再次执行git add、git commit、git push,这将非常复杂。你为什么单击了“-1”?我没有单击“-1”,顺便说一句,我无法更改它,当我更改它时,它将再次变为“-1”,我不知道为什么。@guerda已单击了“-1”。在我记忆中,只有当你有15个名声时,你才能给答案打分。