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.

Machavity
  • 30,841
  • 27
  • 92
  • 100
markets
  • 9,344
  • 7
  • 34
  • 33

13 Answers13

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.

Rakete1111
  • 47,013
  • 16
  • 123
  • 162
Michael Ratanapintha
  • 39,422
  • 4
  • 33
  • 40
  • 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 03 '09 at 03: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.

Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
aminalid
  • 1,156
  • 10
  • 7
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!]).

blueyed
  • 27,102
  • 4
  • 75
  • 71
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).

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
chethan
  • 421
  • 4
  • 2
  • 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 '12 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
sam
  • 40,318
  • 2
  • 41
  • 37
Aaron Dancygier
  • 1,996
  • 19
  • 20
  • 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). – bbaassssiiee Nov 19 '12 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.

Beau Simensen
  • 4,558
  • 3
  • 38
  • 55
  • 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... – edwardsharp Nov 03 '11 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

Danny Schoemann
  • 1,270
  • 26
  • 41
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).

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
Don Wakefield
  • 8,693
  • 3
  • 36
  • 54
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

Kamil Kisiel
  • 19,723
  • 11
  • 46
  • 56
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.

Alan Dong
  • 3,981
  • 38
  • 35
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

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
-1

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

recursive
  • 83,943
  • 34
  • 151
  • 241
-3

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

Sophie Alpert
  • 139,698
  • 36
  • 220
  • 238
  • 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 02 '09 at 02:34