Pio
Pio

Reputation: 4064

Git branching previous commits

I have the following situation.

local repo

What I wanted to do is the following: reset the HEAD to where the master is on the picture. Also I have a branch named backupRestore. Now I want that branch to end with the commit it is created of. So I want to remove the last two commits : Merge branch 'master' of github... and remotes\origin\master. And this way reset the HEAD to master (master on the picture). The problem is that I need to update my github repo, which has different structure (as you can see, remotes/origin/master is the HEAD on github.

UPDATE

After applying the solution my tree looks like this: Solved issue

Upvotes: 3

Views: 101

Answers (1)

VonC
VonC

Reputation: 1323343

If nobody pulled from your GitHub repo, and if you don't have any local work in progress:

git checkout master
git reset --hard master
git push -f -u origin master
git checkout backupRestore
git push -f -u origin backupRestore

Then try a:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --branches --all

And see if the end result looks like what you are describing in your question.

Upvotes: 2

Related Questions