lab 32 Merging Back to Main
Goals
- We’ve kept our greet branch up to date with main (via rebase), now let’s merge the greet changes back into the main branch.
Merge greet into main
Execute:
git checkout main git merge greet
Output:
$ git checkout main Switched to branch 'main' $ $ git merge greet Updating 6179ba3..d81bcbf Fast-forward lib/greeter.py | 6 ++++++ lib/hello.py | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 lib/greeter.py
Because the head of main 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:
git hist
Output:
$ git hist * d81bcbf 2023-08-21 | Hello uses Greeter (HEAD -> main, greet) [Théophile Chevalier] * c004268 2023-08-21 | Add greeter class [Théophile Chevalier] * 6179ba3 2023-08-21 | Added README [Théophile Chevalier] * 9ab61ca 2023-08-21 | Moved hello.py to lib [Théophile Chevalier] * 7abea37 2023-08-21 | Add an author/email comment [Théophile Chevalier] * 1c410c6 2023-08-21 | Add a comment (tag: v1) [Théophile Chevalier] * 0bf384c 2023-08-21 | Display user input (tag: v1-beta) [Théophile Chevalier] * 31c3945 2023-08-21 | Add some content [Théophile Chevalier] * aa5d425 2023-08-21 | First Commit [Théophile Chevalier]
The greet and main branches are now identical.