What is the intended use-case for git stash?

前端 未结 7 1617
野性不改
野性不改 2020-12-22 15:39

If I work on branch A and suddenly need to work on branch B before being ready with a commit on branch A, I stash my changes on A, checkout B, do my work there, then checkou

7条回答
  •  轮回少年
    2020-12-22 16:01

    You can use the following commands:

    • To save your uncommitted changes

      git stash

    • To list your saved stashes

      git stash list

    • To apply/get back the uncommited changes where x is 0,1,2...

      git stash apply stash@{x}

    Note:

    • To apply a stash and remove it from the stash list

      git stash pop stash@{x}

    • To apply a stash and keep it in the stash list

      git stash apply stash@{x}

提交回复
热议问题