SVN: How to commit as a different user

23 09 2009

Today I spend some time to find out how to commit as a different user in SVN.

I did a checkout using svn+ssh by specifying username in the url for example svn+ssh://<username>@server/path/to/repos . The code was checkouted by user1, and this code can be accessed by user2. user2 edited some files and want to commit as user2. Every time when user2 is trying to commit, it is always asking the user1 password.

Actually if we use http or svn protocol, we can use –username attribute in the svn commit but this did not work for svn+ssh.

I tried by using –username, –no-auth-cache parameters in the svn commit but it does not work, always asking the user1 password.

After some time googleing, I went to svn IRC channel and asked there. Finally I am able to solve the problem by seeing the thread http://ubuntuforums.org/showthread.php?t=748131

1. We should change the svn root url to svn+ssh://server/path/to/repos. To change this I used svn switch command. I used following command.

svn --relocate switch svn+ssh://user1@server/path/to/repos svn+ssh://server/path/to/repo

2. Edit /home/user2/.subversion/config. Change the line that reads
#ssh = $SVN_SSH ssh to:

ssh = $SVN_SSH ssh -l <username>

<username> can be any user on the remote machine, but in my case it was user2.

That’s it from now on when I do commit it is asking user2 password.

The second step is not required if logged in username is same as svn+ssh username that you want to use. Suppose if you login to system as user2 and your svn server ssh username is also user2, then you can skip the 2nd step. It will ask user2 password when you try to commit.

Advertisements