When do I need to do “git pull”, before or after “git add, git commit”?

前端 未结 6 937
忘了有多久
忘了有多久 2020-12-22 16:14

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 comm         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-22 16:58

    You want your change to sit on top of the current state of the remote branch. So probably you want to pull right before you commit yourself. After that, push your changes again.

    "Dirty" local files are not an issue as long as there aren't any conflicts with the remote branch. If there are conflicts though, the merge will fail, so there is no risk or danger in pulling before committing local changes.

提交回复
热议问题