Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a Git repository set up. This repository has almost 700 commits, but all of them is in the master branch. I would like to take an approach in which I roll back this master branch (this rollback involves roughly 50 commits) to an earlier point to make it stay there and starting from that point, branch out all later commits into a separate branch.

Graphical explanation

Current state:

|-.---.---.---.---.---.---.---.---+ master
 aaa bbb ccc ddd eee fff ggg hhh  HEAD

Desired state:

|-.---.---.--\-|  master
 aaa bbb ccc  \
               \
                \.---.---.---.---.---+ seperate-branch
                ddd eee fff ggg hhh  HEAD

So that the master branch is rolled back to the ccc commit and every commit from that point (ddd and onwards) are moved into a seperate-branch.

I am fairly new to Git but have got myself to the journeyman levels, still this advanced usage is pretty above my head. I am using Ubuntu 11.04 as my system. The repository (apart from being stored locally) is having a remote set up to GitHub (if this is to make any difference).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to know the commit you want to rollback to, I'm calling it SHA1

git checkout -b seperate-branch
git checkout master
git reset SHA1 --hard

And you're done.

To push it on GitHub, you will need to do

git push --force origin master
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.