Skip to content

Git Branching and Rebasing

Category Git & GitHub
Status โœ… Completed
Repo nextwork-git-branching-and-rebasing
Original NextWork guide nextwork.ai

Learning project

Practice work following a NextWork guide, separate from my production projects.

๐Ÿ“š NextWork learning project. This is a practice project I built while working through NextWork's Git Branching and Rebasing guide. It is part of my Learning portfolio and is fully separate from my production projects.

Category: Learning โ€บ Git & GitHub
Status: โœ… Completed

Overview

I practised intermediate Git skills: resolving a merge conflict by choosing how to combine the changes, rebasing a feature branch so history stays linear, and squashing sloppy commits into one. The editor step of rebase -i is scripted with GIT_SEQUENCE_EDITOR, so it runs unattended.

Summary

Merge conflict, rebase, interactive-rebase squash, and stash all ran. The full output is in docs/verification.txt.

The checks behind this are in docs/verification.txt.

Skills & tools

Git, Merge conflicts, git rebase, Interactive rebase, git stash

What I built

  • practice.sh: the full session, with checks that the rebased branch has no merge commits.
  • Interactive rebase squashes wip, fix typo, and more fixes into Add rebasing notes.
  • Secret mission: stash work in progress, fix main, then stash pop back on the feature branch.

How to run

bash practice.sh            # replays the whole session in a temp folder
bash practice.sh ./sandbox  # or in a folder you choose

Verification

I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.

bash practice.sh

Original project: https://nextwork.ai/projects/91663bbf-e290-4b23-a79a-b5ecb09d033a ยท Part of my NextWork Learning portfolio (hub).

Verification output

From docs/verification.txt:

$ bash practice.sh


=================== Set up the repository ===================

=================== Create and resolve a merge conflict ===================

$ git switch -c feature-status
Switched to a new branch 'feature-status'

$ git switch main
Switched to branch 'main'
$ git merge feature-status
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
# Git Learning Log

<<<<<<< HEAD
Status: published
=======
Status: in review
>>>>>>> feature-status

$ git add README.md

$ git log --oneline --graph -5
*   fefe110 Merge feature-status: keep published, note review
|\  
| * a05d63d Set status to in review
* | 58a5248 Set status to published
|/  
* 6d7ab8a Initial commit

=================== Rebase a feature branch onto main ===================

$ git switch -c feature-notes
Switched to a new branch 'feature-notes'

$ git switch main
Switched to branch 'main'

$ git switch feature-notes
Switched to branch 'feature-notes'

$ git rebase main
Rebasing (1/1)
Successfully rebased and updated refs/heads/feature-notes.

$ git log --oneline --graph -4
* 82bd03a Add rebasing note
* 424b8fa Add license
*   fefe110 Merge feature-status: keep published, note review
|\  
| * a05d63d Set status to in review
OK: straight-line history, no merge commits

=================== Clean up commits with interactive rebase (squash) ===================

$ git log --oneline -4
1ef4a33 more fixes
89c7274 fix typo
8277198 wip
82bd03a Add rebasing note

$ git rebase -i HEAD~4
Rebasing (2/4)
Rebasing (3/4)
Rebasing (4/4)
[detached HEAD b50c895] Add rebasing notes
 Date: Thu Jan 1 09:00:00 2026 -0600
 1 file changed, 4 insertions(+)
 create mode 100644 notes.md
Successfully rebased and updated refs/heads/feature-notes.

$ git log --oneline -3
b50c895 Add rebasing notes
424b8fa Add license
fefe110 Merge feature-status: keep published, note review
commits on feature-notes not on main: 1

=================== Secret mission: git stash ===================

$ git stash push -m WIP notes
Saved working directory and index state On feature-notes: WIP notes

$ git stash list
stash@{0}: On feature-notes: WIP notes

$ git switch main
Switched to branch 'main'

$ git switch feature-notes
Switched to branch 'feature-notes'

$ git stash pop
On branch feature-notes
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   notes.md

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (bf1a42547ccff2eb8f1f39299a6a14448e8637bf)

$ git status --short
 M notes.md

[exit code 0]