When working on different branches in Eclipse, you’ll often find yourself wondering if you’re working in the right workspace for the right branch. This is especially an issue if you have multiple Eclipse instances open and you’re working on different branches of the same codebase, eg. dev, fix, release and feature branches.
There are a number of features in Eclipse that can help you distinguish which window belongs to which branch, including naming your workspace, naming perspectives and colouring your window.
Most features don’t show you the actual branch (ie. its name as it exists in the SCM) but they enable you to manually mark a workspace as belonging to a branch.
Display the workspace name in the window title bar
The easiest way to identify which branch you’re working on, is to name the workspace to make the name appear in the window title bar.
To change the workspace name:
- Go to Window > Preferences > General > Workspace.
- Change the setting Workspace name (shown in window title) to the name of your branch or whatever identifying name you like.
- Click Ok.
Your window title bar should now contain the name you entered as the first bit.
Display the workspace path at the end of the window title bar
Eclipse can also display the workspace path in the window title bar. This is done via a command line argument. The easiest way to enable this is to run Eclipse with -showlocation:
c:\eclipse> eclipse -showlocation
The workspace path will now appear in the title bar at the end of the title.
It’s a bit less useful than naming your workspace as your taskbar may not have enough space to display the path so you can’t easily identify the right window in the taskbar. And sometimes the path doesn’t identify the actual branch.
You can also provide a workspace name at the end, eg. eclipse -showlocation ReleaseBranch. To make the -showlocation take effect every time you invoke Eclipse, you can add it to your eclipse.ini file as a command line argument (above the -vmargs).
Change editor and view colours
You can completely customise the colours of your Eclipse editors and views. This also provides a useful way of distinguishing between two different branches, especially if the window title bar is a bit too subtle for you.
To change the colours, I’d recommend installing the Eclipse Color Theme plugin and choosing one of the themes from the associated site.
To change the colours manually, you can go to Window > Preferences > General > Appearance > Colors and Fonts and change the colours from there. You will have to spend some time fiddling around with the different components though, so using existing themes or importing existing preferences is recommended.
Other ways to identify the branch
Here are some more ways to identify which branch you’re working on, although some may not be as immediately obvious as the ones above:
- Create a perspective and name it accordingly, eg. Java (Release Branch). Since the perspective name is always displayed in the window title, the branch name will also appear there. Unfortunately, you’ll have to do this for all perspectives you use. See Share Eclipse perspective layouts across multiple workspaces for ways to save create a new perspective.
- Open the Package Explorer or Navigator views and look at the label on the projects. That should tell you which branch you’re working on. It is a bit more cumbersome than the other methods, though. Also see Instantly show a class/file in the Package/Project Explorer in Eclipse.
- Share Eclipse perspective layouts across multiple workspaces
- Categorise projects in the Package Explorer to reduce clutter in Eclipse
- Eclipse shortcuts for common SVN commands
- How to share plugins across multiple Eclipse installations and reinstall Eclipse easily
- Compare two workspace or external files in Eclipse