search

Home  >  Q&A  >  body text

How to transfer uncommitted changes in the workspace to a new branch in git?

Suppose my current branch is develop. I forgot to open a new branch before starting new requirements, so I started to modify it directly in the workspace. Halfway through writing, now I want to open a new branch named skin, and put The modifications in the workspace are transferred to the new branch, the modifications in my local develop workspace are cleaned up, and the work is switched to the new branch to continue. How to do it?

怪我咯怪我咯2809 days ago584

reply all(5)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:38:31

    Just switch branches directly

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-02 09:38:31

    Switch branches directly. Local modifications are not bound to the branch. The modifications you made after switching are still there.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:38:31

    git stash, then create a new branch locally and switch to the new branch, then execute git stash pop, you can try it, it should work

    reply
    0
  • 高洛峰

    高洛峰2017-05-02 09:38:31

    Create a new skin branch directly in your local area, and then switch directly to your skin branch

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-02 09:38:31

    $ git checkout -b skin

    reply
    0
  • Cancelreply