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.".
Git command line:
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.".
- Let's merge
masterintobugFix:
git checkout bugFix; git merge master
SincebugFixwas an ancestor ofmaster, git didn't have to do any work; it simply just movedbugFixto the same commitmasterwas attached to.
- Make a new branch called
bugFix - Checkout the
bugFixbranch withgit checkout bugFix - Commit once
- Go back to
masterwithgit checkout - Commit another time
- Merge the branch
bugFixintomasterwithgit merge
Goal:
: - Make a new branch called
Git command line:
$ git checkout -b bugFix
$ git commit
$ git checkout master
$ git commit
$ git merge bugFix
No comments:
Post a Comment