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

前端 未结 6 907
忘了有多久
忘了有多久 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条回答
  •  梦毁少年i
    2020-12-22 16:52

    Best way for me is:

    1. create new branch, checkout to it
    2. create or modify files, git add, git commit
    3. back to master branch and do pull from remote (to get latest master changes)
    4. merge newly created branch with master
    5. remove newly created branch
    6. push master to remote

    Or you can push newly created branch on remote and merge there (if you do it this way, at the end you need to pull from remote master)

提交回复
热议问题