29. Merging to the main
branch
Goals
- We have kept our
style
branch up to date with themain
branch (usingrebase
), but now let's merge thestyle
branch changes back into themain
.
01 Merge style
into main
Run
git switch main
git merge style
Result
$ git switch main
Switched to branch 'main'
$ git merge style
Updating 85c14e9..39a1e0f
Fast-forward
css/style.css | 3 +++
hello.html => index.html | 1 +
2 files changed, 4 insertions(+)
create mode 100644 css/style.css
rename hello.html => index.html (73%)
Since the last commit in main
directly precedes the last commit of the style
branch, Git can merge fast-forward by simply moving the branch pointer forward, pointing to the same commit as the style
branch.
Conflicts do not arise in the fast-forward merge. Also, fast-forward merges do not create a merge commit.
02 Check the logs
Run
git log --all --graph
Result
$ git log --all --graph
* 39a1e0f 2023-11-28 | Renamed hello.html; moved style.css (HEAD -> main, style) [Alexander Shvets]
* 23149b5 2023-11-28 | Included stylesheet into hello.html [Alexander Shvets]
* b9e6de1 2023-11-28 | Added css stylesheet [Alexander Shvets]
* 85c14e9 2023-11-28 | Added meta title [Alexander Shvets]
* ee16740 2023-11-28 | Added README [Alexander Shvets]
* 9288a33 2023-11-28 | Added copyright statement with email [Alexander Shvets]
* b7614c1 2023-11-28 | Added HTML header (tag: v1) [Alexander Shvets]
* 46afaff 2023-11-28 | Added standard HTML page tags (tag: v1-beta) [Alexander Shvets]
* 78433de 2023-11-28 | Added h1 tag [Alexander Shvets]
* 5836970 2023-11-28 | Initial commit [Alexander Shvets]
Now the style
and main
branches are identical.