104

I have 2 svn checkouts that someone setup for me. Now I need to check these same files on another computer, but since I didn't check them out initially I don't know the urls to use when running the svn checkout command:

svn co WHAT_GOES_HERE? 

Since these 2 checkouts already exist on one of my servers, is there a way to get the url of the repo from which they were initially checked out from?

3 Answers 3

158

You can get the URL of the directory you are in, as well as the Repository Root and other info by running the following command in any of the checked out directories:

svn info 

If you want a command that returns only the URL of the repository, perhaps for use in a script, then you can pass the following parameter:

svn info --show-item repos-root-url 

It is worth noting that --show-item is available in Subversion 1.9+. In older versions you can use the following snippet the achieve similar result:

svn info | grep 'Repository Root' | awk '{print $NF}' 
2
  • 6
    Same thing for windows: svn info | findstr /C:"Repository Root: " Commented Oct 11, 2012 at 9:53
  • 1
    To get the relative path for the repository (useful in addition to root URL): svn info --show-item relative-url Commented Oct 11, 2017 at 20:42
13

For SVN 1.7 I had to use

svn info | grep '^URL' | awk '{print $NF}' 

I hope this helps anyone else that comes here with a newer SVN

3
  • The accepted answer is still working for svn, version 1.7.9 (r1462340) compiled Apr 13 2013, 14:22:38. Commented May 18, 2013 at 21:14
  • 4
    @dash17291 it "works" as in it prints something out but not the right info. It returns the repo root which is not what the asker wants. The root is not the repo url (at least not usually). With the above answer you will get repourl.com/root vs mine where you will get repourl.com/root/branch/branch_name or whatever you have checked out. Commented May 20, 2013 at 13:19
  • This also matches "Relative URL" using svn 1.8.10. The grep should be changed to grep "^URL" Commented Aug 3, 2015 at 11:29
4

No need to grep, just use AWK for the search and delimiting the string
svn info | awk '/^URL/{print $2}'

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.