Stash changes while keeping the changes in the working directory in Git

后端 未结 5 1954
庸人自扰
庸人自扰 2020-12-23 00:24

Is there a git stash command that stashes your changes, but keeps them in the working directory too? So basically a git stash; git stash apply in o

5条回答
  •  抹茶落季
    2020-12-23 00:36

    git stash and then git stash apply (git stash && git stash apply) will stash files and apply stash immediately after it. So after all you will have your changes in stash and in working dir.

    You can create an alias if you want it in one piece. Just put something like this to ~/.gitconfig:

    [alias]
        sta = "!git stash && git stash apply"
    

    The drawback of this approach is that all files are stashed and recreated. This means that timestamps on the files in question will be changed. (Causing Emacs to complain when I try to save the file if opened it before I did the git sta, and may cause unnecessary rebuilds if you're using make or friends.)

提交回复
热议问题