Repository navigation
Branching and Merging
bparlaker edited this page Oct 6, 2026
·
2 revisions
A branch lets you work on a feature, fix, or experiment in isolation - main stays stable while you try things.
git switch -c feature/issue-labels # create and switch
git branch # list local branches (* = current)
git branch -a # include remote branchesgit switch main && git pull
git switch -c docs/undoing-changes
# edit files...
git add .
git commit -m "docs: add Undoing Changes page (#4)"
git push -u origin docs/undoing-changes
# open a Pull Request on GitHub, get review, mergeFast-forward - main has not moved, so Git just slides the pointer:
before: A---B (main) after: A---B---C---D (main, feature)
\
C---D (feature)
Three-way merge - both branches moved, Git creates a merge commit M:
A---B---E (main) A---B---E-------M (main)
\ → \ /
C---D (feature) C-------D
git merge feature # fast-forward if possible
git merge --no-ff feature # always create a merge commit (keeps the "this was a feature" bubble)
git merge --squash feature # squash all changes into one new commitgit merge feature
# CONFLICT (content): Merge conflict in README.mdGit marks the file:
<<<<<<< HEAD
Hi! I'm Berker.
=======
Hello, my name is Berker Parlaker.
>>>>>>> feature
- Edit the file to the final version and delete the markers.
git add README.md-
git commit(orgit merge --continue)
Tip: git config --global merge.conflictStyle zdiff3 also shows the common ancestor, which makes conflicts much easier to understand.
| Prefix | Use |
|---|---|
feature/ |
new functionality |
fix/ |
bug fixes |
docs/ |
README / wiki / documentation |
chore/ |
repo maintenance |
Include the issue number: docs/4-undoing-changes.
🎨 Term Project
📘 Git
🗂 Project workflow