• Ch8. Syncing With a Remote
    Ray Wenderlich/Mastering Git 2021. 8. 21. 16:26


    git push origin master
    # master 브랜치를 remote(origin)와 syncronize 하여라!
    git pull origin
    # editor opens
    Merge branch 'master' of https://github.com/belangerc/ideas
    # Please enter a commit message to explain why this merge is necessary,
    # especially if it merges an updated upstream into a topic branch.
    # Lines starting with '#' will be ignored, and an empty message aborts
    # the commit.

    git pull은 git fetch + git merge와 동일하다.

    git push를 실행하기 전에 git fetch를 하는 습관을 들이는 것이 좋다.


    fetch를 한다는 것은 .git 디렉터리에 remote의 모든 commit을 가져온다. 그 다음 Git은 이 commit들을 fast-forward merge할 수 있는지, conflict가 있는지 등을 알수 있게 된다.

    ls .git
    cat .git/FETCH_HEAD
    branch 'master' of https://github.com/belangerc/ideas


    Dealing with multiple remotes

    # Scenario that how to add another remote and merge it
    git remote add crispy8888 https://github.com/crispy8888/ideas.git
    git remote -v
    crispy8888  https://github.com/crispy8888/ideas.git (fetch)
    crispy8888  https://github.com/crispy8888/ideas.git (push)
    origin  https://www.github.com/belangerc/ideas (fetch)
    origin  https://www.github.com/belangerc/ideas (push)
    git fetch crispy8888
     * [new branch]      clickbait  -> crispy8888/clickbait
     * [new branch]      master     -> crispy8888/master
    git checkout clickbait
    git merge crispy8888/clickbait

    'Ray Wenderlich > Mastering Git' 카테고리의 다른 글

    Ch10. Merging  (0) 2021.08.21
    Ch9. Creating a Repository  (0) 2021.08.21
    Ch7. Branching  (0) 2021.08.06
    Ch6. Git Log & History  (0) 2021.08.05
    Ch5. Ignoring Files in Git  (0) 2021.08.05
Designed by Tistory.