Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  • Rationale
  • Commands
  1. Cookbook

Stash

PreviousDiffNextMerge

Last updated 1 year ago

Rationale

Use case: when you've already made some changes, but want to save the changes and apply them later. The reason for this could be you want to apply the changes to another branch.

Commands

  • git stash save the changes

    • git stash save "description" will add a description

  • git stash list show all stashes and their indeces

  • git stash show {stash-index} shows the stash specified by {stash-index}

  • git stash apply apply the last set of changes but keep the stash

    • git stash apply stash@{n} choose a stash to apply

  • git sttash pop similar to apply but removes the stash afterwards.

  • git stash drop {stash-index} removes a stash

  • git stash clear removes all stashes

Further reading

Useful tricks you might not know about Git stash