Giter VIP home page Giter VIP logo

gitsavvy's Introduction

GitSavvy

tests License: MIT

GitSavvy is a powerful and mature plugin for Sublime Text that brings most of Git's functionalities directly into the text editor.

It offers features that just come naturally when in an editor. For example, you can easily interactively stage or discard changes per hunk, per line, per file. Search for specific content that you just select right in the buffer. Navigate through the history of commits and revisions of files, write clear and long(!) commit messages (because who wants to deal with a clunky input box in a separate program for that?). GitSavvy makes standard rebasing actions, like rewording a commit message, trivial, and advanced rebasing techniques, such as splitting a feature branch into two, manageable.

However, GitSavvy enhances your Git experience. It does not replace it.

Installation

Simple

  1. Install the Sublime Text Package Control plugin if you don't have it already.
  2. Open the command palette and start typing Package Control: Install Package.
  3. Enter GitSavvy.

Less simple

If you want more control over what you pull down, or if you'd like to submit changes to GitSavvy (๐Ÿ‘ˆ๐Ÿ‘Œ), you should clone the repository directly in the Packages folder and restart the editor. You still have to run Package Control: Satisfy Dependencies after that!

Note: GitSavvy requires Git versions at or greater than 2.18.0. However, it is highly recommended to use a more recent version of Git, as some advanced rebasing features in GitSavvy require at least version 2.38.0. Upgrading to the latest version of Git will ensure that you can take full advantage of all the features and improvements available in GitSavvy.

Note: GitSavvy does not support Sublime Text 2. If you are using Sublime Text 3, you can access the last supported version by checking out the st3-2.39.1 tag. That's to say, the current main line of GitSavvy only supports Sublime Text versions above build 4000. For the best experience, use the latest Sublime Text dev build. Or not, I mean it could also crash you, what am I to recommend here.

TLDR; aka Quick Start

When you first install GitSavvy, you may not notice any immediate changes to your Sublime Text interface. Except that you may see the checked out branch name and dirty status displayed in the status bar. (You can change this in the settings if you want to.) It's important to note that GitSavvy actually adds a lot of commands to Sublime's Command Palette, which can be accessed by pressing ctrl+shift+p on Windows or cmd+shift+p on macOS. These commands are typically prefixed with git: , while all GitHub features are prefixed with github: .

GitSavvy also comes with dedicated views. In order to get started with GitSavvy, it's a good idea to become familiar with the git: status and git: Repo History views first. These views are a great entry point into the GitSavvy world and will help you get comfortable with the plugin before diving deeper into its other features. (In fact, I did not venture beyond the git: status view for the first year or so but hey, GitSavvy also changed a lot since then.)

By default, the status view shows some helpful information, while in the repo history view, you can get additional help by pressing [?]. The most important keys to remember in the repo history view are [enter] for the main menu and [r] for the rebase menu.

Basic Git Functionality

GitSavvy provides all the essential Git commands such as clone, init, commit, checkout, pull, push, fetch, and many more.

All of these commands and features can be accessed easily through Sublime's Command Palette (ctrl+shift+p). Just start typing the name of the command you want to use, e.g. checkout, and Sublime will quickly select the correct command. You can recognize GitSavvy commands as they are all prefixed with git: .

After you hit enter to select a command, GitSavvy will often start a wizard. For example, typing checkout will show a list of available branches, while typing checkout new branch will ask for the name of the new branch. Note that Sublime's fuzzy logic helps with typing long commands and remembers acronyms you've used in the Command Palette. For instance, on my computer, typing chn followed by enter is enough to create a new branch.

Special Views for Git Status, Branches, and Tags

GitSavvy provides dedicated views for Git status, branches, and tags. Users can access these views by running the git: status, git: branch commands.

In addition to these views, GitSavvy also has sophisticated special views for viewing diffs and patches, making commits, or showing the repository history. However, for new users, running the git: status command may be the first entry point into the GitSavvy world. From here, you can stage ([s]), unstage ([u]), and discard ([d]) changes to whole files. You can also start the commit phase ([c]), open the repository history ([g]), open a diff view ([f]), and push the current branch ([p]).

Tip: if nothing has been staged yet, pressing [c] will default to committing all changes with the -a flag.

Note that views with smaller content like the status view typically display their keyboard bindings directly at the bottom of the screen, while views with larger content, e.g. the repo history, will only show the key bindings in a help popup after you press [?].

Usability Note 1:

GitSavvy comes with a lot of keyboard bindings, but it doesn't include any global shortcuts. This is because adding global shortcuts can conflict with other packages or built-in functionality. However, you can easily add your own global shortcuts by opening Sublime's key bindings file (Preferences: Key Bindings).

For example, you can add a global shortcut to open the status view from anywhere by adding the following to your key bindings file:

{ "keys": ["ctrl+shift+s"], "command": "gs_show_status"}

This will allow you to quickly access the Git status view with the ctrl+shift+s shortcut, no matter what file or view you have open. You can add other shortcuts for other GitSavvy commands in a similar way.

Usability Note 2:

After checking the git status, the second most common action is probably to make a commit. So it is a good idea to make a shortcut here as well. Simply add the following code to Sublime's keybindings:

{ "keys": ["ctrl+shift+c"], "command": "gs_commit"},

gs_commit will open up the commit view in GitSavvy. If nothing is staged yet, it will assume the -a flag and select all changes. However, it will not include untracked files as is typical with Git. Within the commit view, you always see the diff of the changes to be committed at the bottom. Here, you can easily unstage or discard hunks or single lines directly using the keyboard shortcuts [u] and [d]. Note that you can undo a discard by pressing ctrl+z.

Pro-tip: Finding and Running (GitSavvy) Commands

Sometimes you may want to find out which commands to use, along with their optional arguments. You can use Sublime's console, which is a Python REPL, to help you with this.

To open the console in Sublime, press Ctrl + ` on Windows or Linux, or Cmd + ` on a Mac. This will open a panel at the bottom of the window where you can enter commands.

To enable logging of commands, enter the following command in the console:

sublime.log_commands(True)

This will cause Sublime to log all commands executed by the user in the console.

Now, start GitSavvy's Command Palette (ctrl+shift+p) and run a command, such as git: status. After the command has executed, look at the console to see the name of the command and any optional arguments that were passed.

For example, you might see:

command: gs_commit {"amend": true}

Here, gs_commit is the name of the command, and the optional argument passed was {"amend": true}. This information can be useful for learning and customizing GitSavvy's functionality.

Don't forget to turn off command logging when you're done, by entering:

sublime.log_commands(False)

in the console.

Repo History

GitSavvy's Repo History view provides a visual representation of a repository's commit history and is accessible via the git: Repo History command. It's similar to gitk but with more features. When editing a tracked file, you can alternatively use git: File History to open a file-specific history view. But you can also turn any standard Repo History view into a file/folder history view and vice versa by using [l] which opens up a list of all tracked files.

The Repo History view offers additional filtering options. Press [a] to toggle between showing all branches or only the currently checked out branch. Press [f] to open the filter prompt, where you can add filters verbatim, like --author= or -Sfoobar. You can use the up and down arrow keys to access a list of default filters or to see the history of filters you've previously used. Once you've filtered the graph, you can quickly toggle the filter on and off using [F].

Press [s] to enter a special "overview" mode showing only the tip of the branches and the tags. ([a] in that mode will toggle the tags on and off too.)

To move around the commit graph, you can either use your mouse or the up and down arrow keys. If you want to make larger jumps in the graph, you can use the keyboard shortcut alt+up or alt+down, which jumps through the "first-parent" only.

The Repo History view has two main menus. Pressing [enter] will open the standard menu, which provides typical functionality such as checking out, cherry-picking, or reverting the currently selected commit. You can also find basic branch and tag functionality like creating or deleting them. Additionally, you can move branch pointers around (as opposed to resetting) or update branches from their upstream.

You can access a second menu by pressing [r], which is specifically designed for rebasing. This menu allows you to reword commit messages ([W]), edit ([E]) or drop commits, apply fixups, and generally rebase anything onto anything. For example, you can extract a series of commits onto your main branch to make two feature branches out of a convoluted one.

Note the visual connection between fixup commits and the commits they are associated with. When the cursor is positioned on a fixup (or squash) commit, the `[r]`ebase menu will provide a specific action to apply that fixup.

You can review any rebase afterwards. E.g.

Open the `[r]`ebase menu again. (The currently checked out branch is named "which" here.) Show the previous tip of the currently checked out branch side by side. Showing the main menu, maybe show a diff between both variants or undo by selecting "Move ...".

If you encounter merge conflicts that need to be resolved manually, displaying the diff can help ensure that you haven't introduced any unintended changes or made mistakes. (In most cases, the diff will be empty, indicating that both tips are identical in terms of code.) From the main menu you can also choose to "Move" or to "Reset" the branch back to the previous tip, effectively undoing the rebase. "Move" will simply move the branch label, while "Reset" performs your typical reset operation that can also modify Git's staging area and discard uncommitted changes, depending on the mode you choose. Usually choose "Move" here to undo a rebase.

Line History

GitSavvy has a feature called "Line History," also known as git's "wtf?" view. This allows you to view the commit history of specific lines within the repository. It's a great way to quickly research the history of a particular piece of code before using the traditional blame view.

To access Line History, you can start on any normal view by selecting some lines, such as a function, and then issuing the git: Line History command from the command palette. But really, you can start on any diff/patch that GitSavvy shows you.

To make it more seamless, I recommend, again, to make a shortcut. For example, you can add the following to your user keybindings:

  { "keys": ["ctrl+shift+l"], "command": "gs_line_history"},

Once you have that, you can use ctrl+l to select some lines, followed by ctrl+shift+l to follow those lines.

GitSavvy will then show you snippets of commits/patches to show you the evolution of those lines. [o] on such an excerpt will open the complete commit. [O] will display the version of the file as it existed at that specific point in time. And [f] for example will initiate a fixup commit for the commit under the cursor. (Either with the stage, or with all changes if nothing is staged yet, as usual.)

Tip: The Line History is also available from any view where we show a diff or patch. (It is thus available from within the Line History views.) On such a view you don't necessarily have to select any lines, as it will select the current hunk for you by default, giving you the "hunk-history", so to speak.

Even deeper: After [o] or [O] you can navigate around in time with [n] (next) and [p] (previous). You can show the commit's context using [g], and the hunks context by opening the inline diff. That's easier with more keybindings:

  { "keys": ["ctrl+shift+,"], "command": "gs_inline_diff" },
  { "keys": ["ctrl+shift+."], "command": "gs_diff", "args": {"current_file": true} },

That's pretty crazy, right? All views are connected, and you can really navigate around the history.

Git Diff View

GitSavvy provides a git diff view that allows users to stage, unstage, and reset (discard) files, hunks, or individual lines.

Fixup/Squash Helpers

GitSavvy offers fixup/squash helpers that can be accessed from various views, including the "Line History" view.

GitHub Integration

GitSavvy provides GitHub integration that allows users to reference issues/collaborators when committing, open the current file or a commit on GitHub at the selected line, and create a new pull request from the current branch.

GitHub-Style Blame View

GitSavvy offers a "blame" view that shows hunk metadata and allows users to view the commit that made the change, similar to GitHub's blame view.

Documentation

The documentation is probably outdated. Yeah it's sad but you can contribute and I will eventually get onto it but every special view has help available, just press ?.

Feature documentation can be found here. It can also be accessed from within Sublime by opening the command palette and typing GitSavvy: help.

Highlights

Status dashboard Tags dashboard
Display and overview and offer actions to manipulate your project state. View and manipulate local and remote tags.
Diff
Stage, unstage or discard hunks, files or individual lines. (video)
Github integration
Reference issues and collaborators in commits. Open files on GitHub in the browser, with lines pre-selected. Create pull requests. Fork a repository.

gitsavvy's People

Contributors

abusalimov avatar asfaltboy avatar aziz avatar borgand avatar codetriage-readme-bot avatar ddevlin avatar deathaxe avatar divmain avatar dnicolson avatar dufferzafar avatar gwenzek avatar joerchan avatar joreiff avatar joshgoebel avatar kaste avatar kinduff avatar laggingreflex avatar marcinruszkiewicz avatar mreq avatar nicosantangelo avatar old9 avatar p3lim avatar raanan-metanetworks avatar randy3k avatar sindrig avatar stevage avatar stoivo avatar timfjord avatar tomv564 avatar yetithefoot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitsavvy's Issues

`git: tags` view

  • show all local tags
  • add tag
  • delete tag
  • show tags on remote (?)
  • push tags to remote

Teaching mode

  • Before running git commands, display what is about to happen to the user
  • Dry-run mode where commands aren't run, just displayed to the user

File status in gutter

  • icons for inserted, modified lines
  • icon between lines for removed lines
  • gray out icons when changes are staged

Windows keybindings conflict

When in the inline-diff view, you cannot do SUPER-L, as this results in a locked machine. Introduce Windows-specific keybindings that swap SUPER for CTRL across the board.

Enhance commit view interactivity

Follow-up for changes seen in #45.

  • convert commit view to ui.Interface
  • enable region-based retrieval of commit message
  • toggle-able display of relevant diff
  • toggle-able display of commit summary (ala git commit --dry-run, see #107)
  • add embedded syntax-highlighting for diff (defining scope for region)
  • investigate: stage files from commit view

`GitSavvy: submit last failed git command as issue`

For debugging purposes (particularly for those submitting bugs), store the stdin and stdout of the most recent failed git operation. Add command to open web browser with URL along the these lines:

https://github.com/divmain/GitSavvy/issues/new?title=failed%20git%20command%20X&body=some%0Ainput%0Aand%0Aoutput

Rethink module layout

Instead of:

  • root
    • commands
      • git-related commands
      • github-related commands
    • common
      • util
        • actual common code
      • git-related code
      • github-related code
      • some actual common code (view or HTTP related)
    • syntax
      • ...

Consider:

  • root
    • core
      • all git-related commands and shared code
    • github
      • all github-related commands and shared code
    • common
      • http
      • view-related
      • theme-related
      • date-related
      • file-related
      • log / debug
      • etc
    • syntax

Output to panels

Most of the outputs in this plugin is done to the status bar.
I would like to see an option to output to panels, especially for certain actions like commit or push where you'd want to see the output, like a response from the server(s).

Color scheme fails to load for git diff (windows)

I get the attached error message, the color scheme defaults to white with black text, and the changed hunks are unclear (in cached mode it seems like the changed hunks aren't shown at all, in uncached mode the hunks are shown as white text on black but it isn't clear what was removed, changed, added).
gitsavvy-error

`git: branch` view

  • syntax-highlighted view
  • show all local branches
  • checkout branch
  • delete branch (--force)
  • merge branch

Full-featured `git: graph` view

  • syntax highlighted view
  • pressing super+enter on a branch name checks out that branch
  • pressing super+enter on a commit will checkout that commit as detached HEAD
  • pressing enter on a commit displays the full commit message and diff in a separate window

add `git add --edit` equivalent

There's no easy way of telling which hunks or lines are actually staged in the inline diff.
Consider adding a background color to these (e.g. yellow) to distinguish them.

This would be especially useful with #35.

Feature documentation

Add basic documentation including:

  • intro / welcome
  • command palette commands
  • special views, their features, and key-bindings
  • existing GitHub integration features
    • setup API keys
  • docs include context for what it going on under the hood, to help learn git (moved from #12)

Link to docs from README.

Is there a way to configure inline diff background colors?

The default background colors result in a very low contrast because I'm using a light color scheme.
Is there a way to set these color values in the user config?
If not, would you consider to add in the config?

themeGenerator.add_scoped_style("GitSavvy Added Line", "git_savvy.change.addition", background="#37A832")
themeGenerator.add_scoped_style("GitSavvy Removed Line", "git_savvy.change.removal", background="#A83732")

Thanks.

git: blame current file results in AttributeError

git 1.9.3
sublime 3065
ubuntu linux 14.04

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 543, in run_
    return self.run(edit, **args)
  File "/home/oliver/.config/sublime-text-3/Packages/GitSavvy/core/commands/blame.py", line 39, in run
    content = self.get_content()
  File "/home/oliver/.config/sublime-text-3/Packages/GitSavvy/core/commands/blame.py", line 50, in get_content
    blamed_lines, commits = self.parse_blame(blame_porcelain.splitlines())
  File "/home/oliver/.config/sublime-text-3/Packages/GitSavvy/core/commands/blame.py", line 100, in parse_blame
    k, v = re.match(r"([^ ]+) (.+)", next_line).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Helpful message when git unconfigured

  • When path to git cannot be found, notify user and inform that they can either install or enter custom path in User/GitSavvy.sublime-settings.
  • When Git name and email and unconfigured, notify user, prompt for name/email, and configure Git.

Interactive help system

  • help docs written in markdown in docs/
  • wiki-style browsing when user presses super-enter on link
  • open docs to specific page/location when certain flags are set on originating view
  • docs include context for what it going on under the hood, to help learn git moving this requirement to #28.

`git: merge` in command palette

Required merge functionality:

  • git: merge
  • git: abort merge
  • git: merge (rebase) (split out as #26)
  • git: fetch and merge
  • status view reports merge status successfully
    • header
    • files
  • merge information in commit view
  • git: restart merge (untenable at present)
  • git: restart merge for file...
  • disallow inline-diff for file with merge conflict (patch is no longer two-way; it involves working tree, HEAD, and other branch/ref)

Show status.

Can we have a new feature that show repo status in bottom left-hand corner of Sublime Text Window?

`git: submodule`

Special view with:

  • list of all submodules with commit status
  • summary for each submodule
  • initialize new submodule
  • update

`git: rebase`

Thoughts for a rebase dashboard.


  REBASE:  master --> my-feature-branch
  STATUS:  conflict at 221ca4

    โ”ณ (dcc578)
    โ”ƒ
    โœ”  11dc57  some commit message
    โ”ƒ
    โœ”  d0c116  some other commit message
    โ”ƒ          resolved: path/to/some/file.ext
    โ”ƒ
  โ–ธ โœ•  221ca4  message for commit with conflict
    โ”ƒ          conflict: path/to/some/conflicting/file.ext
    โ”ƒ          resolved: path/to/file/already/resolved.ext
    โ”ƒ
    ?  a0891c  message for commit to check next
    โ”ƒ
    ?  5fe330  message for last commit
    โ”ƒ
    โ”ป

  ###############                      #############
  ## CONFLICTS ##                      ## COMMITS ##
  ###############                      #############

  [o] open file                        [s] squash commit with next
  [a] accept file in current state     [S] squash all commits
  [m] use mine                         [u] move commit up (above previous)
  [t] use theirs                       [d] move commit down (below next)
  [M] launch external merge tool       [e] edit commit message

  ####################
  ## REBASE ACTIONS ##
  ####################

  [R] restart rebase
  [A] abort rebase
  [F] finalize rebase

-

Notes:

  • cannot finalize until all commits show a green check mark
  • squash commands would take to commit-like view pre-filled with combined commit messages
  • cannot squash all until all commits show a green check mark
  • cannot squash commit with next until selected and selected's next commit show green check mark

Diff while commiting

When creating a commit, it's handy to see at a glance what you are actually committing, a diff displayed at the bottom is the optimal solution.

Should also be optional, as it would probably add extra load time on larger commits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.