6

I cloned a SVN repository into a git repository using git svn clone. At that point in time, I did not have a username at that site and hence didn't use the --username option of clone. As I can now commit to the SVN repository with my new username, I would like to add that username. Without it, dcommit simply fails:

% LANG=C git svn dcommit 
Committing to <THE URL> ...
RA layer request failed: Server sent unexpected return value (405 Method Not Allowed) in response to MKACTIVITY request for '/svn/!svn/act/0ceca4c5-f7b4-4432-94be-0485559a6040' at /usr/lib/git-core/git-svn line 945.

Is there a way to tell git about a new username? The git-svn manual doesn't seem to help: adding a username is only allowed on init and branch. I don't know how git works with SVN internally, but I guess there should be a way to add a username afterwards.

Note that I am using SVN over http.

3 Answers 3

2

You can specify the username in the dcommit command, e.g.

git svn dcommit --username=isapir
Sign up to request clarification or add additional context in comments.

Comments

0

I think you can use this procedure (from the git svn manpage) to create a clone of your existing svn repository, but change the git svn init step so that it specifies a username. Your new git-svn repository will then have a username.

# Clone locally - make sure the refs/remotes/ space matches the server

    mkdir project
    cd project
    git init
    git remote add origin server:/pub/project
    git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
    git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
    git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched

    git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
    git svn init --username my_new_name http://svn.example.com/project
# Pull the latest changes from Subversion
    git svn rebase

2 Comments

In addition to this, I used theadmin.org/articles/git-svn-switch-to-a-different-a-svn-url to change the URL after setting a new username.
how can i change the username? In my local git commits, I get my username and email id. But when i push to svn, I get the username of the guy who had setup git svn in my system. I tried to run 'git svn --username <myusername>, but i see message that 'GIT_SVN_ID may be set in the environmet .........(a long message)'.
0

Note that if you specify a username, you would not be able to dcommit a merge commit, not before Git 2.16.x/2.17 (Q1 2018).
That is because "git svn dcommit" did not take into account the fact that a svn+ssh:// URL with a username@ (typically used for pushing) refers to the same SVN repository without the username@ and failed when svn.pushmergeinfo option is set.

See commit 8aaed89 (15 Sep 2017) by Jason Merrill (jwmerrill).
(Merged by Jason Merrill -- jwmerrill -- in commit 8aaed89, 17 Sep 2017)

git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.

Previously, svn dcommit of a merge with svn.pushmergeinfo set would get error messages like

merge parent <X> for <Y> is on branch svn+ssh://gcc.gnu.org/svn/gcc/trunk, 
which is not under the git-svn root svn+ssh://[email protected]/svn/gcc!"

So, let's call remove_username (as we do for svn info) before comparing rooturl to branchurl.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.