Wednesday, October 17, 2018

Lesson3: Git merge

Now we need to learn some kind of way of combining the work from two different branches together. This will allow us to branch off, develop a new feature, and then combine it back in.

Merging in Git creates a special commit that has two unique parents. A commit with two parents essentially means "I want to include all the work from this parent over here and this one over here, and the set of all their parents.".

  1. Let's merge master into bugFix:
    git checkout bugFix; git merge master

    Since bugFix was an ancestor of master, git didn't have to do any work; it simply just moved bugFix to the same commit master was attached to.

    • Make a new branch called bugFix
    • Checkout the bugFix branch with git checkout bugFix
    • Commit once
    • Go back to master with git checkout
    • Commit another time
    • Merge the branch bugFix into master with git merge
     Start:

    Goal:





    :
     











Git command line:
                         $ git checkout -b bugFix
                         $ git commit
                         $ git checkout master
                         $ git commit
                         $ git merge bugFix

No comments:

Post a Comment