Git - Stash

About

git stash 1) stashes the changes in a dirty working directory away before a pull/merge to bring them back later with a local merge.

Example: Before a pull or a merge to integrate the remote changes

git stash # keep the modification in a stash branch
Saved working directory and index state WIP on branch name: 17e7b33 Commit message

git pull # get the last one
git stash pop # Destash the modification and merge them

Merge strategy

git stash pop pops the top stash off of the stack and merges it with your working environment. ?

The merge can be also done with cherry-pick to specify the strategy.

git cherry-pick -n -m1 -Xtheirs stash

where:

  • -m1 specifies the first parent as the merge base
  • -n specifies not to commit the result.





Discover More
Git - Conflict resolution

In case of conflict during a merge, the working tree files will include a description of the conflict bracketed by the usual conflict markers <<<<<<< and >>>>>>>. For the marker, Git uses the same style...
Git - Git (executable|command line)

The git executable where: --git-dir is the location of the repository files --work-tree is the location of the work tree Command Description add Add file contents to the index add--interactive...
Branches Git
Git - Branch

This page talks Branch management in Git. For Git, a branch is: a commit name (ref) that points to the last commit (head) leaf in the commit log (or log) that represents a commit chain Example...
git cherry-pick

is a git merge mechanism that allows you to: apply some commits or integrate stashed work to your branch. Apply the change introduced by the commit at the tip of the master branch and create...



Share this page:
Follow us:
Task Runner