Setting local branches before committing

0

I am new to Git and need to make a quick adjustment on my branches.

I started an activity in a wrong local branch "X". I would like to migrate the changes to a local branch "Y" to give commit from "Y" and undo the changes in X.

How do I create a Y branch from local X before undoing X changes?

I'm using Visual Studio 2017 with the Git extension for VS.

    
asked by anonymous 10.11.2017 / 12:41

1 answer

0

First you create a new branch:

git branch Y

It will already be with the modifications made to the X branch. If you want to check if everything is right, make a git checkout Y and test the modifications made.

In branch X to return to the last commit just use:

git revert HEAD~1

Remembering that HEAD~1 will only return a commit (the latter) if you use HEAD~2 will return to two commits and so on.

    
10.11.2017 / 13:00