Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I revert a git-svn branch to SVN HEAD?

Tags:

I have a local git repository which tracks a remote SVN repository via git svn. I have made and committed some changes in the local git repository, but now I'd like to create a branch that reflects SVN HEAD in order to make some changes to the code as it stands in SVN, because I don't want to propagate the changes in my git master to SVN just yet. How can I go about this?

Immediate follow-up: I will need to make and commit changes to SVN HEAD, then merge them back into my git master. How do I go about this? Do I git merge the 'svn-edits' branch into master, or do I do a git svn rebase?

like image 232
saffsd Avatar asked Dec 09 '08 13:12

saffsd


People also ask

How do I clone a branch in SVN?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...

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.


1 Answers

I will assume that the branch you are working on is the one for trunk (I will call it old-trunk). Simply create a new branch from there

git checkout -b real-trunk remotes/trunk

Now make your changes to real-trunk and commit from there. Afterwards, simply rebase your old branch on the new one.

git svn dcommit
git checkout old-trunk
git rebase real-trunk

Now your earlier changes are based on the more recent changes you just did.

like image 86
Bombe Avatar answered Sep 30 '22 17:09

Bombe