ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Git​Gutter

by jisaacks ST2/ST3 Top 25

A Sublime Text 2/3 plugin to see git diff in gutter

Details

Installs

  • Total 410K
  • Win 133K
  • OS X 170K
  • Linux 106K
Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28 Dec 27 Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4
Windows 26 214 220 113 131 188 217 206 217 214 111 121 209 198 211 191 144 74 84 149 164 180 164 130 89 105 164 198 195 182 190 112 109 207 210 212 238 214 132 137 208 254 216 218 136 117
OS X 19 257 238 116 100 220 241 259 298 301 154 150 224 209 260 242 192 71 87 135 170 190 153 143 86 97 141 189 169 200 204 121 117 166 221 231 222 225 106 142 236 229 214 272 159 137
Linux 26 186 168 87 93 164 133 152 155 192 84 88 117 172 153 154 115 61 52 102 101 124 149 103 71 62 110 144 110 140 156 74 91 153 139 158 150 151 103 81 192 167 165 160 81 100

Readme

Source
raw.​githubusercontent.​com

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.

Advanced Features

Diff Popup

diff_popup_screenshot

symbol meaning of the symbol
× close the popup
jump to first change
jump to previous change
jump to next change
≈, ≉ enable/disable difference highlighting
copy the content of the git state
revert changes to the state in git

The diff popup appears if you hover the mouse of the gutter changes. However this functionality is only enabled in Build 3116 or newer. If you are using an older Sublime Text 3 version you can also show the diff popup from the command palette or via a keybinding.

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.

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

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.

Debounce Delay

Delays 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.

Hover Diff Popup

This hover feature is only available in Build 3116 and newer. GitGutter shows a diff popup, when hovering over changes in the gutter. Set enable_hover_diff_popup to false, if you want to disable this popup. You can still open it with a keybinding and from the command panel.

Diff Popup Default Mode

The diff popup is only available in Sublime Text 3 The diff popup has two modes: The default mode to show the previous git state with code highlighting and the diff mode to highlight the differences between the git state and the editor state. You can set diff_popup_default_mode to "default" or "diff" to change the mode in which the popup opens.

Diff Popup Appearance

The diff popup is only available in Sublime Text 3 The popup uses the mdpopups library and the corresponding settings are global and not only for GitGutter. You can change the syntax highlighting style to the same as Sublime Text by adding "mdpopups.use_sublime_highlighter": true to your User settings. Other settings can be found here. In addition the popup loads the css file gitgutter_popup.css, which can be modified by the user and is also accessible via the settings menu.

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. The value may be either a direct string to a git binary: “javascript { "git_binary”: “E:\Portable\git\bin\git.exe” }

Or it may be a dictionary keyed off what sublime.platform() returns, so it may be customized on a per-platform basis:
```javascript
"git_binary": {
  "default": "",
  "linux": "/usr/bin/git",
  "windows": "C:/Program Files/Git/cmd/git.exe"
}

It is valid to use environment variables in the setting value, and they will be expanded appropriately.

In a POSIX environment you can run which git to find the path to git if it is in your path. On Windows, you can use where git to do the equivalent.

Protected Regions

Is GitGutter blocking SublimeLinter or other icons? You can prevent this by adding which regions you would like GitGutter to not override: “javascript "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 <kbd>Project</kbd> > <kbd>Edit Project</kbd> menu and add the `settings` key as shown.
```javascript
{
    "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>

Alternatives

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