A Sublime Text 2/3 plugin to see git diff in gutter
Python JavaScript Ruby Shell Makefile
Latest commit 84b4a3a Jul 18, 2016 @jisaacks committed on GitHub Remove glacier link
Fixes #291
Failed to load latest commit information.
icons Use different delete icons for larger fonts Jan 18, 2014
release_messages Cut 1.2.2 release Dec 23, 2015
.gitignore Do not process untracked files for #204 Jun 16, 2015
Default (Linux).sublime-keymap Added compare against 'origin' and added hotkeys to switch compare ag… Jul 24, 2014
Default (OSX).sublime-keymap Added compare against 'origin' and added hotkeys to switch compare ag… Jul 24, 2014
Default (Windows).sublime-keymap Added compare against 'origin' and added hotkeys to switch compare ag… Jul 24, 2014
Default.sublime-commands Added compare against 'origin' and added hotkeys to switch compare ag… Jul 24, 2014
GitGutter.sublime-settings make sublime linter regions protected by default Mar 23, 2016
LICENSE update license Dec 11, 2012
Main.sublime-menu Fix capitalization of menu items Apr 12, 2015
README.md Remove glacier link Jul 18, 2016
git_gutter.py fix protected_regions check Mar 23, 2016
git_gutter_change.py Wrap setting for next/prev change command Jul 22, 2014
git_gutter_compare.py Merge branch 'git-gutter-compare-against' Jan 8, 2015
git_gutter_events.py Merge branch 'master' of https://github.com/jisaacks/GitGutter Jul 7, 2014
git_gutter_handler.py Cleanup temp_file usage Jun 6, 2016
git_helper.py fix pep8 issue, also added the missing parenthesis Oct 8, 2013
makefile Create build tool for releases Jun 18, 2015
messages.json Cut 1.2.2 release Dec 23, 2015
screenshot.png Add screenshot Dec 10, 2012
view_collection.py Cleanup temp_file usage Jun 6, 2016

README.md

Git Gutter

A sublime text 2/3 plugin to show an icon in the gutter area indicating whether a line has been inserted, modified or deleted.

Screenshot:

screenshot

Installation

You can install via Sublime Package Control:

Or you can clone this repo into your Sublime Text x/Packages:

OSX

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
git clone git://github.com/jisaacks/GitGutter.git

Ubuntu

cd ~/.config/sublime-text-2/Packages
git clone git://github.com/jisaacks/GitGutter.git

Windows

GitGutter assumes that the git command is available on the command line. If it's not, add the directory containing git.exe to your PATH environment variable. Then clone the repo:

cd "%APPDATA%\Sublime Text 2\Packages"
git clone git://github.com/jisaacks/GitGutter.git

On OS X you might need to install the package SublimeFixMacPath.

It's not working!?

The most common reason for the icons to not show up is likely a problem with GitGutter finding the git executable on your path. Please read the section on the git_binary setting for how to fix that.

Comparing against different commits/branches/tags

By default, Git Gutter compares your working copy against the HEAD. You can change this behaviour through the ST command palette. The following options are available:

  • Compare against HEAD
  • Compare against particular branch
  • Compare against particular tag
  • Compare against specific commit

To change the compare option:

  • Open the command palette (Ctrl-Shift-P for Windows/Linux, Cmd-Shift-P for Mac)
  • Start typing GitGutter
  • You'll see the 4 options listed above, select one with the keyboard.
  • Choose the branch/tag/commit to compare against.

Settings

Settings are accessed via the Preferences > Package Settings > GitGutter menu.

Default settings should not be modified, as they are overwritten when GitGutter updates. Instead, you should copy the relevant settings into GitGutter's user settings file.

Non Blocking Mode

When set to true then GitGutter will run in a seperate thread and will not block. This does cause a slight delay between when you make a modification and when the icons update in the gutter.

Debounce Delay

When using non_blocking mode, delay update of gutter icons by the following amount (in milliseconds). Useful for performance issues. Default 1000 (1 second).

Live Mode

By default, GitGutter detects changes every time the file is modified. If you experience performance issues you can set it to only run on save by setting live_mode to false.

Untracked Files

GitGutter shows icons for new files and ignored files. These icons will be on every line. You can toggle the setting show_markers_on_untracked_file to turn this feature off. Defaults to true (shows icons). You may need to add scopes to your color scheme (markup.ignored.git_gutter and markup.untracked.git_gutter) to color the icons.

Minimap

GitGutter will show diffs in the minimap on Sublime Text 3. This can be disabled by setting show_in_minimap to false.

Git path

If git is not found by GitGutter you may need to set the git_binary setting to the location of the git binary, e.g. in a portable environment;

"git_binary": "E:\\Portable\\git\\bin\\git.exe"

Or in a POSIX environment you can run which git to find the path to git if it is in your path.

Protected Regions

Is GitGutter blocking SublimeLinter or other icons? You can prevent this by adding which regions you would like GitGutter to not override:

"protected_regions": ["region", "names"]

You will need to figure out the names of the regions you are trying to protect.

Status Bar Text

You can turn off the status bar text by changing "show_status": "default" to "show_status": "none".

Per-project Settings

Sublime Text supports project-specific settings, allowing live_mode to be set differently for different repositories. To implement, use the Project > Edit Project menu and add the settings key as shown.

{
    "folders":
    [
        {
            "path": "src"
        }
    ],
    "settings":
    {
        "live_mode": false
    }
}

Icon Coloring

The colors come from your color scheme .tmTheme file.

Color schemes that already have support for GitGutter include:

If your color scheme file does not define the appropriate colors (or you want to edit them) add an entry that looks like this:

<dict>
  <key>name</key>
  <string>GitGutter deleted</string>
  <key>scope</key>
  <string>markup.deleted.git_gutter</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#F92672</string>
  </dict>
</dict>
<dict>
  <key>name</key>
  <string>GitGutter inserted</string>
  <key>scope</key>
  <string>markup.inserted.git_gutter</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#A6E22E</string>
  </dict>
</dict>
<dict>
  <key>name</key>
  <string>GitGutter changed</string>
  <key>scope</key>
  <string>markup.changed.git_gutter</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#967EFB</string>
  </dict>
</dict>
<dict>
  <key>name</key>
  <string>GitGutter ignored</string>
  <key>scope</key>
  <string>markup.ignored.git_gutter</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#565656</string>
  </dict>
</dict>
<dict>
  <key>name</key>
  <string>GitGutter untracked</string>
  <key>scope</key>
  <string>markup.untracked.git_gutter</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#565656</string>
  </dict>
</dict>

Jumping Between Changes

There are commands to jump between modifications. The default keybindings for these commands are:

OS X Windows / Linux Description
Command+Shift+Option+k Ctrl+Shift+Alt+k Previous
Command+Shift+Option+j Ctrl+Shift+Alt+j Next

Alternatives

Check out the collection of GitGutter(ish) packages for various editors