Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sublime Text: git plugin
I like being able to quickly ask my editor "what's the history of this file?", without having to jump to another window. This plugin implements just enough git commands to be useful to me at the moment.
I may add more, I may not. If you submit a pull request implementing something I missed, I'll almost certainly accept it.
The easiest way to install this is with Package Control.
- If you just went and installed Package Control, you probably need to restart Sublime Text 2 before doing this next bit.
- Bring up the Command Palette (Command+Shift+p on OS X, Control+Shift+p on Linux/Windows).
- Select "Package Control: Install Package" (it'll take a few seconds)
- Select Git when the list appears.
Package Control will automatically keep Git up to date with the latest version.
More complex methods
First, you need to have
git installed and in your
$PATH. Afterwards you may need to restart Sublime Text 2 before the plugin will work.
$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/ $ git clone git://github.com/kemayo/sublime-text-2-git.git Git
Linux (Ubuntu like distros)
$ cd ~/.config/sublime-text-2/Packages/ $ git clone git://github.com/kemayo/sublime-text-2-git.git Git
Copy the directory to: "C:\Users\<username>\AppData\Roaming\Sublime Text 2\Packages"
Copy the directory to: "C:\Documents and Settings\<username>\Application Data\Sublime Text 2\Packages"
This plugin has a few settings. If you create a file called
Git.sublime-settings in your
User package you can override them. Feel free to copy the
Git.sublime-settings file from the Git package directory to your
User package if you don't want to mess with getting the initial JSON syntax right.
- save_first: whether to save files before running any git operation
- git_command: a path to your git binary if it's not in the $PATH available to Python (you'll get an error message if you need to set this)
- (format for windows:
"git_command": "c:/users/myuserdir/dev/git/bin/git.exe". If you have spaces in your git binary's path, you may need to use the old tilda-escaped version, like: "C:/Progra~2/Git/bin/git.exe".)
Show the status of the repo. Choosing a file gives you a diff of it.
You can view the log, for the current file or for the whole repo.
You can use fuzzy matching on the log details while viewing the log to find interesting commits.
You can see more details about the given commit. This is either restricted to just your current file, or for all files in the repo, depending on how you got to it.
Show uncommitted changes in the current file or the whole repo. Displays with appropriate syntax highlighting.
Get an annotated version of the entire current file, or just the selected lines. (It's ugly now. I might fix it.)
Let Sublime annotate your changes while you are working.
You need to add some custom theme scopes to make them appear in a different color than white. You can copy these sample colors into your theme file, for example ".../Packages/Color Scheme - Default/Monokai.tmTheme"
Choose from a list of modified files to stage for a commit.
Add files lets you choose which files to add. You can either choose individual files or you can choose to add all the files.
After adding files, commit them all with a message. (Close the file without saving it to commit)
Add and commit the current file, after asking for a message.