How to git stash only untracked files?

前端 未结 1 1316
遥遥无期
遥遥无期 2021-02-05 06:03

I want to only stash all untracked files. I know it can be done with two commands, by first stashing tracked changes and then untracked, but can it be done with one line command

1条回答
  •  深忆病人
    2021-02-05 06:30

    You can do it with alias in ~/.gitconfig:

    stash-untracked = "!f() {    \
        git stash;               \
        git stash -u;            \
        git stash pop stash@{1}; \
    }; f"
    

    And then just do

    git stash-untracked
    

    0 讨论(0)
提交回复
热议问题