I just discovered that even though the rebase
section in git help svn
says
This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.
(my emphasis) it doesn't mean that rebase
includes a git svn fetch
. Naming aside, is there some way to run a single git svn
command to do both?
The reason I want to do this is that I only write on one branch, so I want to rebase
that one and I frequently read other branches, so I want to fetch
those.
You can clone a subversion repository to your machine using git svn clone <SVN repo URL> . The code will be available as a git repository. You can do your work there and make local commits as you please. There is a command line option to get a "shallow" checkout rather than the entire repository which is often useful.
Normally, the "git svn clone" and "git svn rebase" commands attempt to recreate empty directories that are in the Subversion repository. If this option is set to "false", then empty directories will only be created if the "git svn mkdirs" command is run explicitly. If unset, git svn assumes this option to be "true".
As detailed in the rewriting history page, rebasing can be used to change older and multiple commits, committed files, and multiple messages. While these are the most common applications, git rebase also has additional command options that can be useful in more complex applications.
The git svn clone command transforms the trunk, branches, and tags in your SVN repository into a new Git repository. Depending on the structure of your SVN repo, the command needs to be configured differently.
I think you're confusing git rebase
and git svn rebase
. The former moves commits up to your current HEAD onto some revision you specify, whereas the latter moves your current HEAD onto the tip of the Subversion branch you're on.
git svn rebase
does include a git svn fetch --parent
, ie it will get any new Subversion commits on the branch you're currently on, but not any Subversion commits from any other branch (contrast with a plain git svn fetch
, which fetches from all branches).
I suspect you don't want to do a full git svn fetch
when you do a git svn rebase
, as it'll mean it'll be much longer before you get a usable working copy. If you want regular git svn fetch
es, I'd advise setting up a cron job that'll do the fetch in the background for you.
I'm also a bit surprised to hear that this is actually the way it behaves. But, to answer your question, you just need to define an alias:
git config --global alias.refetch '!git svn fetch && git svn rebase'
Then git refetch
should do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With