Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Being careful is usually enough to prevent problems, but sometimes I need to double check the branch I'm working on (e.g. "hmm... I'm in the dev branch, right?") by checking the source control path of a random file.

In looking for an easier way, I thought of naming the solution files accordingly (e.g. MySolution_Dev.sln) but with different file names in each branch, I can't merge the solution files.

It's not that big of a deal but are there any methods or "small tricks" you use to quickly ensure you're in the correct branch? I'm using Visual Studio 2010 with TFS 2008.

share|improve this question
2  
This sounds like a good candidate for a VS 2010 Extension to be written which allows some sort of configurable visual cue to indicate the branch. Perhaps colorizing the background of the Solution Explorer as per user settings (I'd do green for Dev, yellow for QA and red for Prod). –  Jesse C. Slicer Oct 14 '11 at 15:58
    
Nice idea, even an indicator on VS title bar would help. –  henginy Oct 14 '11 at 16:10
1  
I'd say that should be pretty effective. I have my bash prompt set to include my git branch and whether the source files are clean or if they need a checkin –  Daenyth Oct 14 '11 at 16:58
    
Does TFS not have something equivalent to git status or hg status? –  user8 Oct 14 '11 at 17:59
    
I use VS user interface for TFS operations, so I don't really have an idea. –  henginy Oct 16 '11 at 10:44

10 Answers 10

up vote 11 down vote accepted

I am using this http://visualstudiogallery.msdn.microsoft.com/f3f23845-5b1e-4811-882f-60b7181fa6d6

Updates your title to for example:

Development\myproject

or

Main\myproject

or

Release\myproject

Hope it helps

share|improve this answer
    
That seems to do it, I'll give it a try.. –  henginy Jul 2 '13 at 13:02
    
I use this extension for exactly this purpose. In fact, I was about to post the link, when I saw that ynnok already had. –  Bobson Jul 2 '13 at 13:29
1  
I ended up using this one as I can see it in the title on which branch I am. Really awesome!!! –  ppumkin Aug 20 '13 at 9:54
    
Yes, it's indeed very convenient! –  henginy Dec 5 '13 at 22:04

Lots of answers here already, but none that touches on the simple solution we have where I work: for each branch, create a new VM containing a dev environment, and check out from the proper branch. You only have to do that and get it right once, and then you just switch VMs to switch branches.

share|improve this answer

I've been using VSCommands extension (with Visual Studio 2012, but there is a 2010 version) and it conveniently puts the branch name in the upper left corner of the screen as well as into the solution explorer.

Not affiliated with the product in any way, just a happy user.

share|improve this answer
    
It looks cool bad sadly you got to pay for all the extra stuff that might not be needed :( –  ppumkin Aug 20 '13 at 10:04

There's a free Visual Studio extension called TFS Solution Info that may help with this. It shows you the current branch and workspace in a little window that you can dock/pin wherever you want.

share|improve this answer
    
Look awesome but does support VS2012 –  ppumkin Aug 20 '13 at 9:54

A specific answer depends on the version control software that you're using, but there's usually a command that lets you easily see the branch you're working on. For example, with Subversion, use the svn info command in a directory to see the URL for that branch. If you're more interested in a particular file, you can specify that too:

caleb-dev$ svn info foo.c 
Path: foo.c
Name: foo.c
URL: https://svn.mycompany.com/repo/sample/branches/caleb-dev/foo.c
Repository Root: https://svn.mycompany.com/repo/sample
Repository UUID: d62f7aef-3ad2-6098-12a-c16647d854ab
Revision: 1042
Node Kind: file
Schedule: normal
Last Changed Author: caleb
Last Changed Rev: 1031
Last Changed Date: 2011-06-07 15:28:27 -0400 (Tue, 07 Jun 2011)
Text Last Updated: 2011-06-08 03:08:12 -0400 (Wed, 08 Jun 2011)
Checksum: 123456789098765432123456789098

From the URL, I can see that my copy of foo.c is in the caleb-dev branch.

I don't need to do that very often because my local directory has the same name as the branch. A quick look at my command line prompt is usually enough to confirm that I'm in the right directory, and therefore working in the right branch.

share|improve this answer

I avoid working in the wrong branch by doing almost everything in one branch (in trunk - per so called "unstable trunk" branching strategy).

The cases when I am forced to update branches are pretty rare - these are pre-and post-production bugfixes (prod candidate code is isolated in branches). Since these fixes should be in trunk too, I typically draft, test and verify them right there in trunk, then port to prod branch. Porting as a rule involves just a straightforward copy of 1 to 5 files to branch and build check.

  • I am also somewhat lucky that in most of my projects management preferred to convince customers to use newer releases instead of patching old ones - this brings post-production part of updates in branches to almost negligible minimum.
share|improve this answer
    
It's indeed nice not to have to maintain previous releases. In that case I'd only use a branch for experimental purposes I guess. –  henginy Oct 16 '11 at 10:35
    
@henginy I can't recall cases when I had a luxury of not having to maintain previous releases at all. However, management attitude can make a big difference here: depending on it one can eg either implement 1-2 hotfixes/year in older branches or mess with these half of all the time –  gnat Oct 16 '11 at 20:39

I do a lot of my (D)VCS work from the command line. I highly reccomend having your prompt display where you are at. For instance, my prompt when in a Git repo looks like (I do this for SVN too):

[BranchName]RepoTop/path/to/current/wd >>

And if the repo is currently dirty (uncommitted changes):

[BranchName!!]RepoTop/path/to/current/wd >>

I also have the background set to red if logged into prod, things like that. I find simple visual notifications to be super effective for me.

You mentioned that you often see this most after coming back to your computer. I find a post it note, with my current focus (branch, bug #, feature) stuck to my keyboard when I leave, to be super effective in allowing me to get back to work quickly, rather than recreate whatever it was I did last.

share|improve this answer

I don't work in a generic dev or trunk branch.

I ALWAYS do work in feature branches. When a feature is done, I follow these steps.

  1. Open Source Control Explorer.
  2. Merge from dev into current feature branch.
  3. Fix any conflicts and ensure everything still works.
  4. Check in again. Merge feature into dev branch.
  5. Open dev solution.
  6. Checkin dev branch.
  7. Close dev solution.
  8. Let CI build and deploy.

I only have the dev branch open for a few minutes at a time and close it right away.

share|improve this answer
    
Thanks for sharing your practice. –  henginy Oct 14 '11 at 14:45

You could create an empty file in each branch, e.g THIS_IS_TRUNK.txt in trunk, and THIS_IS_DEV.txt in DEV.

share|improve this answer
2  
That might actually work..Especially with an underscore in front of the file name to move it up in solution explorer. –  henginy Oct 14 '11 at 14:02

Name the working directories differently. That is, if your project is titled "MY_PROJECT," create a different working directory for each branch. If there is one branch named "dev," then you'd need a directory for trunk and a directory for dev, like this:

~/henginy/projects/MY_PROJECT-trunk
~/henginy/projects/MY_PROJECT-dev
share|improve this answer
    
Actually working directories are named differently. But with an already open Visual Studio, (for example after I take a coffee break and return to my desk) I have to check the path of a file to see the directory. So I guess it's the simplest way and no escape from that? –  henginy Oct 14 '11 at 13:18
2  
@henginy That's a good clarification. To determine that in Visual Studio, I hover over the tab of an open file. It will display a tooltip of the full file system path, from which I can determine whether the root is "-dev" or "-trunk." Try that and see if it works for you. –  Matthew Rodatus Oct 14 '11 at 13:45
1  
Yes, that is exactly how I "check the source control path of a random file", and I'm trying to find a quicker way:) –  henginy Oct 14 '11 at 13:59
    
@henginy Oh, right. You said that in OP. I don't know of a better way off the top of my head. Sounds like I haven't improved on your situation at all. :-( –  Matthew Rodatus Oct 14 '11 at 16:18
    
I should've clarified that better in my question. Thank you for your help! –  henginy Oct 16 '11 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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