Skip to content

Instantly share code, notes, and snippets.

@jpettersson
Created December 12, 2014 09:44
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpettersson/4a719e12a03cdfc91ef1 to your computer and use it in GitHub Desktop.
Save jpettersson/4a719e12a03cdfc91ef1 to your computer and use it in GitHub Desktop.
Git: Apply changes from branch as unstaged changes on other branch
Sometimes that "quick" refactor takes longer than I was planning for. Then it's nice to commit changes to a temporary "dirty" feature branch just to have an off-laptop backup and change history. I use this method for storing a bunch of trash commits on a feature branch and then lifting them back over to master when I want to continue work / clean up.
# Check out the branch you want to start working from
git checkout master
# Check out the dirty "refactor" branch as staged changes
git checkout refactor -- .
# Reset will unstage the changes
git reset
Time to clean up!
@queglay
Copy link

queglay commented Nov 26, 2020

This is a handy workflow tip. Is it possible to get similar behaviour with submodules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment