Merging
git merge brings another branch into the current one. If main has not moved, Git simply fast forwards. Otherwise it creates a merge commit. Use --no-ff to always make one.
Example
echo base > a.txt; git add .; git commit -q -m "base"
git switch -q -c feature
echo f > f.txt; git add .; git commit -q -m "add f"
git switch -q main
echo m > m.txt; git add .; git commit -q -m "add m"
git merge -q --no-edit feature
ls
git log --format=%sResult
a.txt f.txt m.txt Merge branch 'feature' add m add f base
Exercise
Merge feature into the current branch.
git feature
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.