Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm cloning a popular open source project into GitHub, and I only realized this after it was too late. I'm also trying to convert this project over to use Maven instead of Ant/Ivy for a build tool. I was able to convert the repository from SVN to Git via the aptly-named svn2git, then started making changes toward the Maven migration.

I failed to realize at the get-go that I needed to create a separate branch for my Maven migrations. Is there a way for me to take my revisions, remove them from master, and send them to a new branch?

share|improve this question
up vote 3 down vote accepted

This sounds really simple to fix assuming you made all your commits to master. Here's a high-level description of the steps (tailor commands to your specific repo).

  • Make a new branch at your current HEAD (e.g. with git branch <newbranch>)

  • Switch to the current master (git checkout master).

  • Track down your original master HEAD commit and move there (e.g. git reset --hard HEAD~n).

  • When pushing to a remote repository, use --force to foist the undoings onto the repository (for example: git push --force --all)

share|improve this answer
@TKKocheran: Thanks for the edit and catching the --force bit. – jw013 Jan 16 '12 at 23:14

Your Answer


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.