🗂️ Stash Management

  • Stash current changes with a message: Save your current changes and include a message for reference.

    git stash push -m "WIP: feature X"
  • List all stashes: Display all saved stashes in your repository.

    git stash list
  • Apply the most recent stash: Restore the most recent stash without removing it.

    git stash apply
  • Apply a specific stash: Restore a specific stash by its identifier.

    git stash apply stash@{2}
  • Drop a specific stash: Remove a specific stash by its identifier.

    git stash drop stash@{0}
  • Pop the most recent stash: Restore and immediately delete the most recent stash.

    git stash pop

🔄 Rebase Workflow

  • Rebase current branch onto master: Replay commits from your branch onto the master branch.

    git rebase master
  • Interactive rebase for the last 5 commits: Modify commit history for the last 5 commits interactively.

    git rebase -i HEAD~5
  • Continue rebase after resolving conflicts: Proceed with the rebase after resolving merge conflicts.

    git rebase --continue
  • Abort the rebase process: Cancel the rebase and return to the original state.

    git rebase --abort
  • Skip the current commit during rebase: Bypass the conflicting commit and continue rebasing.

    git rebase --skip

🍒 Cherry-Pick Commands

  • Apply a specific commit to the current branch: Bring a specific commit from another branch to the current branch.

    git cherry-pick commit-hash
  • Cherry-pick a range of commits: Apply multiple commits from a range to the current branch.

    git cherry-pick start-commit^..end-commit

🔀 Merge Conflict Management

  • Abort a merge in progress: Cancel the current merge and revert to the pre-merge state.

    git merge --abort
  • Continue a merge after resolving conflicts: Resolve conflicts, add changes, and complete the merge.

    git add conflicted-file
    git commit