Merging Back to Master

Goals

  • We’ve kept our greet branch up to date with master (via rebase), now let’s merge the greet changes back into the master branch.

Merge greet into master

Execute:

  1. git checkout master
  2. git merge greet

Output:

  1. $ git checkout master
  2. Switched to branch 'master'
  3. $
  4. $ git merge greet
  5. Updating 8d90176..e0cc19e
  6. Fast-forward
  7. Rakefile | 2 +-
  8. lib/greeter.rb | 8 ++++++++
  9. lib/hello.rb | 6 ++++--
  10. 3 files changed, 13 insertions(+), 3 deletions(-)
  11. create mode 100644 lib/greeter.rb

Because the head of master is a direct ancestor of the head of the greet branch, git is able to do a fast-forward merge. When fast-forwarding, the branch pointer is simply moved forward to point to the same commit as the greeter branch.

There will never be conflicts in a fast-forward merge.

Review the logs

Execute:

  1. git hist

Output:

  1. $ git hist
  2. * e0cc19e 2020-06-20 | Updated Rakefile (HEAD -> master, greet) [Jim Weirich]
  3. * 046088a 2020-06-20 | Hello uses Greeter [Jim Weirich]
  4. * 3db0ffe 2020-06-20 | Added greeter class [Jim Weirich]
  5. * 8d90176 2020-06-20 | Added README [Jim Weirich]
  6. * 5aec14d 2020-06-20 | Added a Rakefile. [Jim Weirich]
  7. * 721b979 2020-06-20 | Moved hello.rb to lib [Jim Weirich]
  8. * 907a445 2020-06-20 | Add an author/email comment [Jim Weirich]
  9. * 4254c94 2020-06-20 | Added a comment (tag: v1) [Jim Weirich]
  10. * c8b3af1 2020-06-20 | Added a default value (tag: v1-beta) [Jim Weirich]
  11. * 30c2cd4 2020-06-20 | Using ARGV [Jim Weirich]
  12. * 4445720 2020-06-20 | First Commit [Jim Weirich]

The greet and master branches are now identical.