Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer

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
1  
@TKKocheran: Thanks for the edit and catching the --force bit. –  jw013 Jan 16 '12 at 23:14
add comment

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.