Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-svn rename tracking branch

Tags:

My current svn cloned branches (using the -s 'standard layout') option are called:

$ git branch -r branch1 branch2 

I would like to rename those, such that they are:

$ git branch -r svn/branch1 svn/branch2   

As though I had called $ git-svn clone --prefix svn originally. I don't need to change any names on the remote side.

like image 890
Gregg Lind Avatar asked Dec 07 '10 21:12

Gregg Lind


People also ask

Can I rename a branch in SVN?

Because branches and tags are ordinary directories, the svn move command can move or rename them however you wish.

How do I change the name of my remote branch?

Rename a Remote Git Branch There isn't a way to directly rename a Git branch in a remote repository. You will need to delete the old branch name, then push a branch with the correct name to the remote repository. The output confirms that the branch was deleted.

Can I rename a branch in git?

The git branch command lets you rename a branch. To rename a branch, run git branch -m <old> <new>. “old” is the name of the branch you want to rename and “new” is the new name for the branch.

How do I change a branch name in bitbucket?

To summarize the other answers: No, there is no way to rename. You can copy and delete, to achieve a similar effect. But if there is, say, a pull request in progress, you can't avoid losing the comments and approvals. this seems to me to be an annoying missing feature of bitbucket!


1 Answers

Assuming that you do not have another remote that was added with git remote add ..., try this procedure:

  1. git gc to package all refs into .git/packed-refs.
  2. Open .git/packed-refs for editing. Replace "refs/remotes/" with "refs/remotes/svn/".
  3. Open .git/config for editing. You should see something like:

    [svn-remote "svn"]     url = SVN_REPO_URL     fetch = trunk:refs/remotes/trunk     branches = branches/*:refs/remotes/*     tags = tags/*:refs/remotes/tags/* 

    Replace "refs/remotes/" with "refs/remotes/svn/":

    [svn-remote "svn"]     url = SVN_REPO_URL     fetch = trunk:refs/remotes/svn/trunk     branches = branches/*:refs/remotes/svn/*     tags = tags/*:refs/remotes/svn/tags/* 

    Be sure to also update any remote-tracking branches. To do this, you can just replace "refs/remotes/" with "refs/remotes/svn/" in the entire file.

I tested this procedure with a copy of my git-svn mirror of the GNU Nano repository and it seems to work.

EDIT: I have just verified that this procedure does not mess up the git-svn dcommit or rebase operations. It is as if --prefix=svn/ were originally specified in the git svn clone -s SVN_REPO_URL command.

like image 83
Daniel Trebbien Avatar answered Oct 10 '22 12:10

Daniel Trebbien