Version Control

TextMate will detect when a project is using Git, Mercurial, Subversion, or Perforce. When detected, it will add attr.scm.«system» as an attribute scope. This is to allow the proper bundle to be active, for example the actions in the Git bundle has a scope selector of attr.scm.git so that they only show under Bundles → SCM (⌘Y) when TextMate has detected, that git is used as version control system.

For Git, Mercurial, and Subversion, TextMate will call out to the appropriate shell command which, for each of the respective version control systems, can be set as the following variables: TM_GIT, TM_HG, and TM_SVN. If no variable is set, TextMate will try to find the shell command via the search path.

TextMate asks the version control system for a few values, which are exposed both as dynamic variables of the form TM_SCM_«variable» and as attr.scm.«variable».«value» attribute scopes. For example if the version control system reports that the current branch is master then the TM_SCM_BRANCH variable will be set to master and attr.scm.branch.master will be part of the current scope. The variable is mostly useful for decorating the window title.

TextMate also asks the version control system for file status. File status is used to add badges to file icons and to show deleted items as ghost items in the file browser, which allow selecting such items before using Bundles → SCM → Commit (⌘Y) or Bundles → SCM → Revert… (⌘Y). You can see a list of modified and untracked files in your project by selecting File Browser → SCM Status (⇧⌘Y) or click the SCM icon in the file browser’s bottom tool bar.

TextMate also has bundles for the various version control systems which provide actions to see uncommitted changes, commit changes, and much more. It is outside the scope of this manual to document how each of these bundles work. Though on a general note, the actions will normally work with selected items in the file browser, falling back to entire project if there is no selection, which makes File Browser → SCM Status (⇧⌘Y) a very useful feature along with the File Browser → Select None (⇧⌘A) action.

It is worth mentioning that the line numbers in the diff renderings produced by actions in the Git bundle can be clicked, and will take you to the clicked line.

If you wish to disable the SCM badges, TextMate’s built-in version control support can be controlled using the scmStatus setting with the properties system, it can be set to one of the following values:

enable
Always enabled.
disable
Always disabled.
enableIfLocalDisk (default)
Enabled for local disks. This should mean that TextMate will not try to obtain SCM info for network mounted drives, as that will generally be slow due to how modern version control systems work (they need to read the full content of every file in your repository).
enableIfSystemDisk
Enabled only for the system disk. This exists incase TextMate does not properly detect a high-latency file systems as non-local.