3 ms·
In git, a use case for rebase that I'm intimately familiar with is interoperability with SVN. You can maintain a branch that's a mirror of an SVN repository, bu
by mechanical_fish 18y ago
In git, a use case for rebase that I'm intimately familiar with is interoperability with SVN. You can maintain a branch that's a mirror of an SVN repository, but if you do any merging and then try to check the results into SVN the result is a train wreck. In the somewhat acid words of the git-svn manpage:
Running git-merge or git-pull is NOT recommended on a branch you plan to dcommit from. Subversion does not represent merges in any reasonable or useful fashion; so users using Subversion cannot see any merges you've made. Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommit may commit to the wrong branch.
The proper technique is to make a branch based on your SVN repo, make a bunch of changes on the branch (using svn rebase to keep your development branch in sync with changes on the SVN master branch, and -- god help us -- diff-and-patch if you have to merge in changes from some other git branch; this is your penance for working on an SVN-hosted project), then commit the whole thing back to SVN once you have it in shape. It sucks compared to true-blue git but is still nicer than SVN, because (e.g.) you get things like...
... the other use case for rebase, git-rebase --interactive, a.k.a. "take the last N commits and let me reorder, combine, and edit them however I want." I love this feature. See:
http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive http://blog.madism.org/index.php/2007/09/09/138-git-awsome-n...
For more useful ravings about git's features:
http://tomayko.com/writings/the-thing-about-git http://tomayko.com/writings/the-thing-about-git
- gecko 18y agoI'm not going to try to sell you on Mercurial vs. git, mostly because I think that argument is pointless, but just so you're aware, Mercurial also supports reordering and combining patches via mq. And that's an area where I personally feel that Mercurial's method actually makes more sense than git's, though you're welcome to disagree. [Edit: Oh, and: yes, that's a perfect example of where rebasing makes sense, and is exactly the kind of rebase operation Mercurial now fully supports, without any complicated patch wrangling.]