何时需要做“git pull”,在“git add,git commit”之前还是之后? [英] When do I need to do "git pull", before or after "git add, git commit"?
本文介绍了何时需要做“git pull”,在“git add,git commit”之前还是之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
git add foo.js
git commit foo.js -m提交
git pull
git push
或者
git pull
git add foo.js
git commit foo.js -mcommit
git push
或
git add foo.js
git pull
git commit foo.js -mcommit
git push
UPD:
我忘记提及在这种情况下,我使用 git add
来放映一个跟踪的和修改的文件。不要将全新的文件包含到存储库中。这是否改变了命令的顺序?
解决方案
pull = fetch + merge。
您需要提交您在合并前完成的操作。
因此,在提交后拉动。
What is the right way?
git add foo.js
git commit foo.js -m "commit"
git pull
git push
Or
git pull
git add foo.js
git commit foo.js -m "commit"
git push
Or
git add foo.js
git pull
git commit foo.js -m "commit"
git push
UPD:
I forgot to mention that in this case I use git add
to stage a tracked and modified file. Not to include a brand new file to repository. Does this changes an order of commands?
解决方案
pull = fetch + merge.
You need to commit what you have done before merging.
So pull after commit.
这篇关于何时需要做“git pull”,在“git add,git commit”之前还是之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文