Subversion switch: How can I see which branch is current?
Asked Answered
G

5

46

We're experimenting with Subversion as a possible replacement of our current Starteam 2005 SCM, (so our SVN knowledge is limited at the moment :-)).

I've been experimenting with the switch command (using the TortoiseSVN client) and was surprised that, after I switched my local trunk folder to a certain branch there is no way to see which branch I switched to last. Or at least I can't find a way to ascertain that.

Am I doing something wrong here by switching a local trunk folder to a branch? How can I see which branch the current local trunk-folder is referring to?

Gesture answered 20/5, 2011 at 11:31 Comment(2)
Have you considered git as an alternative? I've worked at a couple of organisations that were using svn and in both cases they have moved (or are moving to) git for new projects. Check out whygitisbetterthanx.com.Alidaalidade
@Richard Ev: C'mon! You forgot about "sister projects": ex- whyhgisbetterthanx.com (sadly, that Hg's version is now unavailable :-/) and ex- whybzrisbetterthanx.comGeophilous
G
51

Though a couple of correct answers have already been provided, I want to point out that there are several more techniques one may use to see where you are in Subversion. Here is the complete list:

  1. Windows Explorer -- Windows Explorer has the flexibility to add columns from a large set of choices beyond the standard name, size, type, and modified date. Right click on the column headers bar, select More from the context menu, then scroll down to the SVN choice. SVN short URL is the best choice for this question since it begins the path with either trunk or branches. Requires TortoiseSVN installed. Caveat: Available in Windows XP but not later ones (Windows Vista, Windows 7, etc.). Sigh...

SVN location from Windows Explorer

  1. TortoiseSVN Revision Graph -- The revision graph is apparently not well known but is a great visual tool for answering many questions, including this one. You have to enable the display of the current revision with the indicated button in the tool bar. Once you do that, TortoiseSVN adds a bold line around the current version of the object you are examining, whether on the trunk or a branch. Caveat: TortoiseSVN does not always find the current version. As I was preparing this illustration, it did not highlight anything in the graph when I was on the branch.

SVN location from Revision Graph

  1. TortoiseSVN Repo-Browser -- Open the repo browser on a file or folder and examine either the URL at the top or the path in the left hand navigation pane. (Any other TortoiseSVN dialogs displaying a URL will show the information similarly as pointed out by @fsonmezay.) SVN location from Repo Browser

  2. File properties -- From Windows Explorer or equivalent, open the standard file properties dialog--not the TortoiseSVN properties! Then select the Subversion tab to see all the information available from the command line, including the URL that indicates trunk or branch in the path. It requires TortoiseSVN to be installed (previously mentioned by @Cedric).

SVN location from file properties

  1. Command-line -- svn info or svn info filename provides details of your current directory or specified file, respectively, including the URL that indicates trunk or branch in the path (previously mentioned by @Cedric).

SVN location from command line

Gondola answered 23/5, 2011 at 17:32 Comment(0)
I
10

You should retrieve this information in the output of svn info, which is available as a command-line feature or available in the TortoiseSVN sub menu when right clicking on an SVN item. Here is the TortoiseSVN explorer integration help, you should obtain all the information about this integration and the available commands. The output of svn info is almost displayed in the Properties item.

Interpretative answered 20/5, 2011 at 11:38 Comment(3)
See my answer : I've edited it to mention it's actually the equivalent of svn info.Singleaction
@Gesture : the svn info command is to enter on a console interface, but the informations are displayed in the properties menu item as mentioned by SolarBearDispenser
I guess you mean the "standard" windows file properties? Because the Properties item from the TortoiseSVN menu doesnt show this infoGesture
S
7

The answers from Cédric and fsonmezay are right ; also, if you're on Windows, you can simply right-click a file or directory, select "Properties" and then go to the Subversion tab. There's the full URL of where that file resides on your repo, so it's very easy to tell from which branch it comes from (e.g. https://my.company.com/svn/branches/somebranch/...).

This is the information you'd get from using svn info from the command line.

Singleaction answered 20/5, 2011 at 11:54 Comment(2)
now there's a feature i hadn't thought of .. I didn't know there was a subversion Tab added to the file properties. thanksGesture
Yep, there's lots of information there - pretty much all the info you'd get from a command line svn info. Also, you can access the file's properties (if you use them) from the button on the bottom of the window, as well as a show log button if you need info not shown there. Very handy !Singleaction
R
0

This may only work in limited scenarios where you do all your Subversion work in a single directory tree, but I've found something that is working pretty well for me.

Whenever I create a new branch, I create an empty folder with the branch name, prefixed with a ".@" so it always sorts to the top in File Explorer. The folder then gets checked in with the branch. Then whenever I do a switch, the previous "branch name folder" is removed and replace with the one belonging to the switched-in branch. I can usually tell at a glance which branch I'm on -- as long as I remember to create the name folders. Thus, it's not as automatic as having the File Explorer display the branch name as one of the columns (I'm on Windows 10, so I can't add Subversion fields to File Explorer).

Rupertruperta answered 28/9, 2021 at 3:59 Comment(0)
L
-1

When you right-click in the folder and run "TortoiseSVN -> Switch" command, the "Switch to Branch / Tag" window appears on the screen. The information you're looking for, is in the "To URL" section. Which shows your current branch.

Lawanda answered 20/5, 2011 at 11:39 Comment(1)
That is what i already described as what i do to switch. My question was how to determine the branch i switched to afterwardsGesture

© 2022 - 2024 — McMap. All rights reserved.