Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git svn fetch + rebase in one operation?

Tags:

git

git-svn

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.

like image 665
l0b0 Avatar asked Mar 21 '12 15:03

l0b0


People also ask

Can I use Git and SVN at the same time?

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.

What does Git SVN rebase do?

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".

What Git rebase exactly does choose multiple?

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.

What is Git svn clone?

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.


2 Answers

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 fetches, I'd advise setting up a cron job that'll do the fetch in the background for you.

like image 125
me_and Avatar answered Nov 13 '22 01:11

me_and


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.

like image 8
Matt McHenry Avatar answered Nov 13 '22 00:11

Matt McHenry