A branch is nothing but a pointer to a certain commit. As @LethalProgrammer said in the comments, the HEAD
of your current branch is the commit it points to. Origin
now is something completely different, it's the default name for the remote repository (i.e. the repository on the server, where you pull
from and push
to).
When you're on branch v4000
with Z
as it's HEAD
(your current state as far as I understand), you can just create a new branch v4100
and reset
the v4000
branch back to Y
.
On the command line, this looks like this:
git stash
stash any uncommited changes
git branch v4100
create branch v4100
with Z
as it's head
git reset --hard Y
with Y
being the commit' s SHA id: reset branch v4000
's HEAD
to commit Y
git stash pop
restore previously stashed changes, if any
You can also do this via VSTeamExplorer, but I don't know how to stash there, so be sure that you have no uncommited changes before you try this:
Select Branches
-> New Branch
, enter v4100
as branch name, uncheck Checkout branch
and click create. This creates branch 4100
with commit Z
as it's HEAD
.
Then, still in the Branches
tab, select Actions
->View History
. In the opening window, right-click commit Y
and select Reset
-> Delete Changes (--hard)
.
EDIT: As always, be careful when using git reset --hard
either way, since it can potentially result in data loss.
Just this description should be enough to convince you that using git via command line is cleaner and it's much easier for people to explain stuff via native git commands. And,as @axiac recommended in the comments, reading the Git Book is definitely worth the time.