96

I found a lot of examples on how to change the username for specific revisions and so on.

But what I need is this: I did a checkout with the authentication credentials of a workmate and need to change it to my credentials for future commits.

I cannot just checkout with my credentials due to the many changes that have been done already...

Anyone familiar with this?

2

12 Answers 12

76

You can change the user with

  • Subversion 1.6 and earlier:

    svn switch --relocate protocol://currentUser@server/path protocol://newUser@server/path
    
  • Subversion 1.7 and later:

    svn relocate protocol://currentUser@server/path protocol://newUser@server/path
    

To find out what protocol://currentUser@server/path is, run

svn info

in your working copy.

3
  • 6
    I get an error "svn: E155024: Invalid source URL prefix: 'protocol://currentUser@server/path' (does not overlap target's URL 'protocol://newUser@server/path')" [with my real URLs, of course]
    – James
    Commented Jul 16, 2012 at 17:53
  • 4
    This doesn't work for plain http-auth authenticaton schemes. See this answer for how to delete the saved user credentials for that use case. @James that's probably your issue.
    – Caleb
    Commented Jul 25, 2012 at 12:00
  • Brilliant stuff.. Thnaks :) Commented Nov 27, 2012 at 7:13
73

The easiest way to do this is to simply use the --username option on your next checkout or commit. For example:

svn commit --username newUser

or

svn co --username newUser

It will then be cached and will be used as the default username for future commands.

See also: In Subversion can I be a user other than my login name?

4
  • I did that, and then svn info and I see no change in the Author line.
    – vsync
    Commented Nov 30, 2014 at 10:31
  • 2
    From the link above: "when Subversion is accessing the repository directly off the file system, it uses your file system permissions to access the repository. (When you connect via SSH tunneling, SVN uses your FS permissions on the server, as determined by your SSH login.) So svn checkout --username may not work for your repository." Commented Nov 30, 2014 at 13:42
  • 1
    @MattBrowne is correct. a path like "svn+ssh://svn.server.com" will not honor the --username change. The accepted answer which uses relocate was the only way I could change it.
    – FlipMcF
    Commented Mar 2, 2016 at 17:19
  • this is perfectly worked for me. thank you @MattBrowne
    – Nani
    Commented Apr 11, 2022 at 14:42
53

I’ve had the exact same problem and found the solution in Where does SVN client store user authentication data?:

  1. cd to ~/.subversion/auth/.
  2. Do fgrep -l <yourworkmatesusernameORtheserverurl> */*.
  3. Delete the file found.
  4. The next operation on the repository will ask you again for username/password information.

(For Windows, the steps are analogous; the auth directory is in %APPDATA%\Subversion\).

Note that this will only work for SVN access schemes where the user name is part of the server login so it’s no use for repositories accessed using file://.

2
  • 1
    Worth noting, that if you run IntelliJ IDEA you also have to restart IntelliJ for the changes to take effect
    – AndersG
    Commented Sep 19, 2012 at 12:24
  • 1
    the fgrep command should have a -l, so that the command tells you the file path. I was going to edit it, but it isn't long enough.
    – vguzmanp
    Commented Jun 21, 2013 at 7:07
22

The command, that can be executed:

svn up --username newUsername

Works perfectly ;)

P.S. Just a hint: "--username" option can be executed on any "svn" command, not just update.

6

Go to Tortoise SVN --> Settings --> Saved Data.

There is an option to clear Authentication Data, click on the clear button, and it will allow you to select which connection you wanted to clear userid/pwd for.

After you do this, any checkout or update activity, it will reprompt for the userid and password.

5

If your protocol is http and you are using Subversion 1.7, you can switch the user at anytime by simply using the global --username option on any command.

When Ingo's method didn't work for me, this was what I found that worked.

0
2

for Win10 you should remove this folder and close/open your IDE

C:\Users\User\AppData\Roaming\Subversion\auth

, also in my projects no ".subversion" folders, only ".svn"

1

Also, for those who happened to realize too late, that they committed with the wrong credentials, the solution (after the fact) is to change the svn author of that revision: see this question

Basically the syntax is:

svn propset --revprop -r (revision_number) svn:author (new username)
1

Based on Ingo Kegel's solution I created a "small" bash script to change the username in all subfolders. Remember to:

  1. Change <NEW_USERNAME> to the new username.
  2. Change <OLD_USERNAME> to the current username (if you currently have no username set, simply remove <OLD_USERNAME>@).

In the code below the svn command is only printed out (not executed). To have the svn command executed, simply remove the echo and whitespace in front of it (just above popd).

for d in */ ; \
do echo $d ; pushd $d ; \
url=$(svn info | grep "URL: svn") ; \
url=$(echo ${url#"URL: "}) ; \
newurl=$(echo $url | sed "s/svn+ssh:\/\/<OLD_USERNAME>@/svn+ssh:\/\/<NEW_USERNAME>@/") ; \
echo "Old url: "$url ; echo "New url: "$newurl ; \
echo svn relocate $url $newurl ; \
popd ; \
done

Hope you find it useful!

0

I believe you could create you own branch (using your own credential) from the same trunk as your workmate's branch, merge from your workmate's branch to your working copy and then merge from your branch. All future commit should be marked as coming from you.

0

You could ask your colleague to create a patch, which will collapse all the changes that have been made into a single file that you can apply to your own check out. This will update all of your files appropriately and then you can revert the changes on his side and check yours in.

0

Tortoise on windows specific:

I attempted the above solution to no available. In my use case, the credentials where stored in the windows Credential Manager under the Windows Credential section and TortoiseSVN refused to change them by running the --username command.

You can edit the credentials by expanding the url for your repo and clicking edit.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.