git stash changes apply to new branch ?

git stash changes apply to new branch ?

Asked on January 10, 2019 in Git.
Add Comment


  • 2 Answer(s)

    Is not working for standard procedure.

    • make changes
    • git stash save
    • git branch xxx HEAD
    • git checkout xxx
    • git stash pop

    Smaller:

    • make changes
    • git stash
    • git checkout -b xxx
    • git stash pop
    Answered on January 10, 2019.
    Add Comment

    Git stash changes apply to new branch:

    git stash branch <branchname> [<stash>]
    
    

    From the docs (https://www.kernel.org/pub/software/scm/git/docs/git-stash.html):

    Creates and checks out a new branch name to  starting from the commit . Originally created, applies the changes recorded in <stash> to succeeds and reference of the form [email protected]{<revision>}, it then drops the <stash>

    Since the stash is applied on top of the commit  at the time, git stash was run  it restores the originally stashed state with no conflicts.

    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.