如果文件在添加和提交后被修改,则如何提交文件

时间:2013-03-26 09:00:53

标签: git

我遇到问题git add today.c然后我git commit today.c,通过此步骤,文件today.c已被修改(我使用shell脚本进行此修改),然后我将文件推送到origin master,但文件仍然相同,未修改,但在我的工作目录中,today.c确实已被修改。

如何将修改后的文件推送到origin master

2 个答案:

答案 0 :(得分:0)

如果您在文件中提交更改,然后将更改推送到另一个分支,则只有提交被推送到此分支(在您的情况下),origin

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

请参阅此解释说明集:

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.

答案 1 :(得分:-1)

四光,请你做以下几点吗? git add today.c
git commit -m 'modify'
git push origin master
并再次检查。

相关问题