Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch svn branches using git-svn?

Tags:

Duplicate

How do I make git-svn use a particular svn branch as the remote repository?

I am using git-svn to track development by someone else on svn. I'm trying to figure out how to use gti-svn to switch from one svn branch to another. All the examples I have able to find talk about using svn switch as method to switch location instead of actual branches.

Essentially, I would like to start pulling from /svn/branch/1.3 instead of /svn/branch/1.2 using svn fetch.

like image 357
Jauder Ho Avatar asked Apr 08 '09 07:04

Jauder Ho


People also ask

How do I switch to a branch in svn?

When you svn switch your working copy to the branch, the local changes will remain. You can then test and commit them to the branch. You can , however, use svn switch with the --relocate switch if the URL of your server changes and you don't want to abandon an existing working copy.

How do I switch between remote branches?

In order to switch to a remote branch, make sure to fetch your remote branch with “git fetch” first. You can then switch to it by executing “git checkout” with the “-t” option and the name of the branch.

Can you use git with svn?

The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.

How do I switch between branches without committing?

you can do git checkout -m <branch-name> to merge conflicts and checkout to the branch and resolve conflicts yourself, or git checkout -f <branch-name> to ignore changes.


2 Answers

These commands have been incredibly useful for me when working on svn branches via git-svn:

#create local Git branch that mirrors remote svn branch  git checkout -b local/RELEASE-0.12 RELEASE-0.12  #will connect with a remote svn branch named ‘RELEASE-0.12′  # -n will show which svn branch you will commit into: git svn dcommit --dry-run  

See full explanation in my article on justaddwater.dk.

like image 146
Jesper Rønn-Jensen Avatar answered Sep 22 '22 12:09

Jesper Rønn-Jensen


If you've cloned the SVN repository properly (using -T -b -t or -s), you should be able to use the git branch commands like:

git reset --hard remotes/branch  git checkout branch 

etc.

like image 23
Can Berk Güder Avatar answered Sep 18 '22 12:09

Can Berk Güder