268

I'd like to know how to get Subversion to change the name that my changes appear under.

I'm just starting to use Subversion. I'm currently using it to version control code on an XP laptop where I'm always logged in under my wife's name. I'd like the subversion DB to show the changes under my name.

Later on I'll replicate the DB so it is accessible to the whole house. My wife uses the office computer where she is always logged in under my name. I'll probably set it up so that it automatically checks in modified documents... preferably under her name.

Eventually I'll probably be using it from a linux machine under another username.

Is there some way to modify the user environment to change the user name that Subversion calls you? I'd expect something like setting SVN_USERNAME='Mark' which would override however it usually gets the name.

Update: It looks like the --username flag that Michael referred to does work to change the name reported by "svn stat", even for local file: repositories. In addition, it is sticky so you don't need to specify it for the next command. I even rebooted and it still used the "--username" value from my previous boot.

13 Answers 13

291

Most Subversion commands take the --username option to specify the username you want to use to the repository. Subversion remembers the last repository username and password used in each working copy, which means, among other things, that if you use svn checkout --username myuser you never need to specify the username again.

As Kamil Kisiel says, when Subversion is accessing the repository directly off the file system (that is, the repository URL is of form file:///path/to/repo or file://file-server/path/to/repo), it uses your file system permissions to access the repository. And when you connect via SSH tunneling (svn+ssh://server/path/to/repo), SVN uses your FS permissions on the server, as determined by your SSH login. In those cases, svn checkout --username may not work for your repository.

1
  • Thanks for the quick answer. The --username flag appears to be very sticky, even across reboots. And it works fine on my file: repository.
    – markets
    Jan 3, 2009 at 3:43
74

For svn over ssh try:

svn list svn+ssh://[user_name]@server_name/path_to_repo  

svn will prompt you for the user_name's password.

2
  • 1
    Doesn't work with usernames like: johndoe@example.com
    – neoneye
    Nov 22, 2013 at 12:15
  • 4
    https://user_name@.../path didn't work for me (cygwin) but --username works fine.
    – zelanix
    Aug 18, 2014 at 16:35
46

You can setup a default username via ~/.subversion/servers:

[groups]
yourgroupname = svn.example.com

[yourgroupname]
username = yourusername

Please be aware that older versions of svn do not support it (e.g. 1.3.1 [sic!]).

42
"svn co --username=yourUserName --password=yourpassword http://path-to-your-svn"

Worked for me when on another user account. You will be prompted to enter username/password again though. You need to login like the above once and you are all set for the subsequent times(Unless you restart your machine).

1
  • 5
    Take care when supplying the password on the command line. Anyone who can see the process list on the machine will be able to see the password in the process list. Fine on a single-user system, but not so good on a multi-user system.
    – bleater
    Sep 27, 2012 at 23:31
12

If you need to specify a username other than your logged in user for use with svn+ssh just add an entry to your .ssh/config file:

Host example.com
User jdoe
1
  • man ssh_config will tell you all about it. I have found no way yet to make this dynamic (for instance based on environment variable). Nov 19, 2012 at 12:24
11

Subversion usually asks me for my "Subversion username" if it fails using my logged in username. So, when I am lazy (usually) I'll just let it ask me for my password and I'll hit enter, and wait for the username prompt and use my Subversion username.

Otherwise, Michael's solution is a good way to specify the username right off.

1
  • 2
    I consider this a better answer because it works for all SVN commands (checkout, commit, etc) where the --username flag seems to either be non-existant or slightly different for various commands... Nov 3, 2011 at 22:17
8

Most of the answers seem to be for svn+ssh, or don't seem to work for us.

For http access, the easiest way to log out an SVN user from the command line is:

rm ~/.subversion/auth/svn.simple/*

Hat tip: http://www.yolinux.com/TUTORIALS/Subversion.html

7

Using Subversion with either the Apache module or svnserve. I've been able to perform operations as multiple users using --username.

Each time you invoke a Subversion command as a 'new' user, your $HOME/.subversion/auth/<authentication-method>/ directory will have a new entry cached for that user (assuming you are able to authenticate with the correct password or authentication method for the server you are contacting as that particular user).

6

I believe if you use the file:// method to access your subversion repository, your changes are always performed under the user which accesses the repository. You need to use a method that supports authentication such as http:// or svn://.

See http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.serverconfig.choosing

2

If you are using svn+ssh to connect to the repository then the only thing that authenticates you and authorizes you is your ssh credentials. EVERYTHING else is ignored. Your username will be logged in subversion exactly as it is established in your ssh connection. An excellent explanation of this is at jimmyg.org/blog/2007/subversion-over-svnssh-on-debian.html

2

Go to ~/.subversion/auth/svn.simple/*, and you will see a list of files that contains the information about your svn user account. Just delete all others that you don't need.

After that, when you do anything that regards to SVN operation, such as commit, rm, etc,. You will be prompt again to enter username or passwords.

-1

TortoiseSVN always prompts for username. (unless you tell it not to)

2
  • No it doesn't. Not on 1.9.5 for Linux, at least.
    – drkvogel
    Oct 9, 2019 at 15:21
  • It uses your local username by default, which is not always what you want when connecting to a remote repository.
    – drkvogel
    Oct 9, 2019 at 15:26
-3

I believe you can set the SVN_USER environment variable to change your SVN username.

1
  • 3
    Can you provide a reference for that? I did a search and found only svn_username, which is a patch that someone made and I can't tell if it made it to the mainline or not... I would think I would have found other hits if so.
    – markets
    Jan 2, 2009 at 2:34

Your Answer

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

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