Git stash uncached: how to put away all unstaged changes?

前端 未结 4 783
孤城傲影
孤城傲影 2021-01-30 00:27

Suppose two set of changes are made in a project versioned by git. One set is staged and the other is not.

I would like to recheck staged changes by running my project a

4条回答
  •  萌比男神i
    2021-01-30 01:24

    The accepted answer also stashes staged changes as a few have pointed out. Here's a way to do it without getting your staged changes in the stash.

    The idea is to do a temporary commit of your staged changes, then stash the unstaged changes, then un-commit the temp commit:

    # temp commit of your staged changes:
    $ git commit --message "WIP"
    
    # -u option so you also stash untracked files
    $ git stash -u
    
    # now un-commit your WIP commit:
    $ git reset --soft HEAD^
    

    At this point, you'll have a stash of your unstaged changes and will only have your staged changes present in your working copy.

提交回复
热议问题