Skip to main content
The Mixed Bag sequence teaches you various Git techniques and practical tips that don’t fit neatly into other categories, but are incredibly useful in day-to-day development.

Overview

This sequence combines several important Git features that you’ll use regularly: grabbing specific commits, juggling commits to reorder them, creating tags for milestones, and using git describe to find your position in history.

Levels in This Sequence

1. Grabbing One Commit

What you’ll learn: How to isolate and move a single specific commit. Key concepts:
  • Sometimes you just need one commit from a branch
  • Use cherry-pick or rebase -i to grab specific commits
  • Useful when you made commits on the wrong branch
  • Helps keep commit history clean
Goal: Use cherry-pick or interactive rebase to move a specific commit. Example scenario:
# You made a bug fix on the wrong branch
git checkout main
git cherry-pick C4  # Grab just the bug fix commit
Alternative approach:
git rebase -i main  # Opens dialog to select commits
Cherry-pick is fastest when you know the commit hash. Interactive rebase is better when you need to visually select commits.

2. Juggling Commits

What you’ll learn: How to reorder commits and make changes to earlier commits. Key concepts:
  • Sometimes you need to modify commits that aren’t the most recent
  • Use rebase -i to reorder commits
  • Can use --amend to modify the currently checked-out commit
  • Combine these techniques to edit commit history
Goal: Reorder commits and make changes to specific ones in the sequence. Example workflow:
# Reorder to bring older commit to top
git rebase -i HEAD~3

# Make changes and amend
git commit --amend

# Reorder back
git rebase -i HEAD~3
This pattern is common when you realize you need to fix something in an earlier commit before continuing work.

3. Juggling Commits #2

What you’ll learn: Advanced commit reordering with cherry-pick. Key concepts:
  • Cherry-pick can solve commit juggling problems
  • You can specify exact commit order
  • Useful when you know exactly what you want
  • Often cleaner than interactive rebase for simple reordering
Goal: Use cherry-pick to grab commits in a specific order. Example:
# Want commits in order: C3, C1, C2
git cherry-pick C3
git cherry-pick C1  
git cherry-pick C2

4. Git Tags

What you’ll learn: How to create permanent markers in your commit history. Key concepts:
  • Tags permanently mark specific commits as milestones
  • Unlike branches, tags never move
  • Used for releases, major milestones, etc.
  • You can checkout tags like commits (enters detached HEAD)
  • Can reference tags in other commands
Goal: Create tags at specific commits and checkout to a tag. Commands introduced:
git tag <tag-name> <commit>  # Create a tag at a commit
git tag v1 C1                # Tag commit C1 as v1
git checkout <tag-name>      # Checkout to a tag
Example workflow:
# Tag version releases
git tag v0 main~2  # Tag old commit as v0
git tag v1 side~1  # Tag another commit as v1

# Reference tags
git checkout v1    # Jump to version 1
git diff v0 v1     # Compare versions
Tags are perfect for marking releases like “v1.0”, “v2.0”, or milestones like “beta”, “production-release”.

5. Git Describe

What you’ll learn: How to describe your position relative to the nearest tag. Key concepts:
  • git describe helps you see where you are in history
  • Output format: <nearest-tag>_<numCommits>_g<hash>
  • Shows closest tag, number of commits since tag, and abbreviated hash
  • Useful for versioning and understanding your location
Commands introduced:
git describe <ref>  # Describe position of ref
Example output:
git describe main
# Output: v1_2_gC5
# Meaning: 2 commits past tag v1, at commit starting with C5

git describe side  
# Output: v2_1_gC8
# Meaning: 1 commit past tag v2
Goal: Use git describe to understand your position relative to tags.
If there are no tags in your repository, git describe will fail. Always tag your releases!

Common Patterns

Here are some practical scenarios where these techniques shine:

Pattern 1: Fix a Commit in the Middle

# Bring old commit to top
git rebase -i HEAD~4

# Make your fix
git commit --amend

# Put everything back
git rebase -i HEAD~4

Pattern 2: Mark and Find Releases

# Tag releases
git tag v1.0 main
git tag v2.0 develop

# Find your position  
git describe HEAD
# v2.0_3_gf6b2c1a (3 commits past v2.0)

Pattern 3: Cherry-pick from Another Branch

# Grab specific commits from feature branch
git checkout main
git cherry-pick feature~2
git cherry-pick feature~1

Commands Reference

CommandPurposeExample
git cherry-pick <commit>Copy specific commitsgit cherry-pick C2 C4
git rebase -i <location>Interactive reorder commitsgit rebase -i HEAD~3
git commit --amendModify the last commitgit commit --amend
git tag <name> <commit>Create a taggit tag v1 C1
git describe <ref>Describe positiongit describe main

What’s Next?

After completing the Mixed Bag sequence:
  • Advanced Topics: Take on challenging rebase scenarios
  • Remote Repositories: Learn to collaborate using push, pull, and fetch
  • Remote Advanced: Master complex remote scenarios

Keep Learning

Continue with more advanced Git concepts

Build docs developers (and LLMs) love