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?

1 Answer 1


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)

  • 1
    @TKKocheran: Thanks for the edit and catching the --force bit.
    – jw013
    Jan 16, 2012 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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