git - how to merge to a local branch after checking out to a previous commit -


I am working on a local branch VISS . Then I decided to see the previous commitment:

git checkout 98ea3c8042c39e

I made some significant changes to the code. And then I've committed it again.

Now I need to go back to my branch VISS to make these changes.

What should I do if I want to:

  1. Removing my VISS from the branch, which is the previous committ ( 98ea3c8042c39e ) was checked before checking out. VISS .

  2. Go back to my VISS branch, merge new changes with the works done by me on top of VISS .

    1. Go back to your branch and Abandon everything:

        git checkout VISS   

      your new commit left floating in the middle of nowhere Will, and will eventually collect garbage by Git.

      By contrast, if you are ready to create 98ea3c at the top VISS and leave it VISS currently Pointing to, do the following:

        git checkout VISS git reset - Hard 98ea3c    
    2. Back VISS < / Code> and merge your new changes at the top of it:

        # You only get new commitments: Git rebase VISS # Abc123 "; So: GIT checkout VISS GIT merge ABC 123   

      Now you will have the code change with VISS , and there will be no merge commitments.

Comments