More for my own reference than anything else…
I have an SVN repository cloned locally. I’ve made a couple of changes in order for my application to run locally and I committed those all against the “dev” branch I set up.
I then go off and do some actual work, which then needs to get sent back upstream to SVN. This is my workflow.
Starting in the dev branch, with all of my changes committed…
-
Because I should be making sure I have the newest stuff from SVN, just in case
git svn rebase
-
Switch over to the master, which should mimic SVN
git checkout master
-
Bring master up to date with the dev branch
git rebase dev
-
Remove the commits I don’t want to push back to SVN
git rebase -i git-svn
-
Because I’m paranoid and want to make sure only the commits I want are actually coming through
git svn dcommit --dry-run
-
Commit it off to SVN
git svn dcommit
Changing History
Revise the last 37 commits. Opens up a log in $EDITOR where you can ‘squash’ commits together
git rebase -i HEAD~37 |
Undoing crazy rebases
-
Find the commit you want to bring back, copy it’s sha1 starter
git reflog
-
Boom, commit is back.
git cherry-pick <sha1 starter></sha1>