Git – working on wrong branch – how to copy changes to existing topic branch

Git – working on wrong branch – how to copy changes to existing topic branch

Asked on January 10, 2019 in Git.
Add Comment


  • 4 Answer(s)

    Existing topic branch :

    git stash
    git checkout branch123
    git stash apply
    

    You need  to back on branch without touching the master branch.

    Answered on January 10, 2019.
    Add Comment

    Top of Google is”working on the wrong branch” to checkout the branch to be working on. No need to hoard anything:

    git checkout branch123
    
    

    Checkout the modified file  to stop  overwrite  the working directory,

    Update : This method will  work when the files is modified in the working directory for both master and branch123.

     

    Answered on January 10, 2019.
    Add Comment

    Try this below solution for git stash :

    Refer this following links which given   Git-Tools-Stashing

     

    Answered on January 10, 2019.
    Add Comment

    his scenario works at least with VS 2015 Git plugin but would most likely work with any git tool.

    1. checkout and make changes to files in master (ups!, wrong branch)
    2. create a new branch “temp” (or any unused name you choose) from master. Checked out files will now be checked out in temp and not in master.
    3. check in changes to temp (master is untouched)
    4. Everything is now checked in and it is possible to check out an existing branch. Check out the wanted branch (the branch I wanted to make the changes to begin with) 3.5 Git Rebase
    5. merge temp to the wanted branch. Now the changes are in the correct branch.
    6. delete the temp branch as it is not needed any more
    Answered on February 20, 2019.
    Add Comment


  • Your Answer

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