Keyboard Shortcuts to Master Your Git Flow in Visual Studio

Jessie Houghton

One popular way for users to optimize their efficiency is to leverage shortcuts to interact with the UI. With Git tasks, like Committing, Pulling, and Pushing being part of your daily workflow, learning how to avoid leaving the keyboard for the mouse can keep you in the zone.

Git Shortcuts
Open Git Changes and shift focus to the Commit Message box Alt+G, C
Open the Git Repository Window Alt+G, M
Open the Branch Picker from the status bar Ctrl+Alt+F3
Open the Repository Picker from the status bar Ctrl+Alt+F4
Open the network operations context menu from the status bar Ctrl+E, Ctrl+C

Checkout some other shortcuts on this printable keyboard shortcut cheatsheet for Visual Studio available for download.

Try out the following Git keyboard workflows to see which shortcuts you can work into your daily practice. Not only can they help you be more productive and iterate quicker, but they can be easier to access for folks who don’t want to or are unable to move the mouse.

Create a New Branch with the Status Bar

Image Branch Picker Shortcut

Often, the first action of a new bug fix or some feature work is to create a new branch. To complete this action without using the mouse:

  • Use Ctrl+Alt+F3 to open the Branch Picker from the status bar.
  • Use Tab, then Enter to select the option for New Branch.
  • Type in the name of your new branch, then use the Tab key to cycle between the rest of the items (Shift+Tab cycles in the reverse direction, once the first item is in focus – meaning there’s a slim, dotted border around it, you can navigate using the Up and Down Arrow Keys).
    • For the dropdown menu tap Enter to open it, and navigate using the Up and Down Arrow Keys, using Enter to make your selection or Esc to exit the dropdown menu.
    • For the checkbox tap the Space to toggle it.
  • Use r or arrow/tab to Create and tap Enter to complete the action.

Commit Your Changes Faster

Once you update your code use Ctrl+S to save your work, then commit your changes without using the mouse:

  • Use Alt+G, C to focus the commit message text box in the Git Changes Window via the Top Level Menu.
  • Type your commit message, tapping Ctrl+Enter to commit all staged files or all changes if nothing is staged.
    • If you’d like to review your changes before committing, see the alternative flow below
  • Shift+Tab to back cycle to the Push icon and tap Enter to Push your changes.

Alternate Flow – Use the Diff View to quickly preview your changes

  • Tab to the document group you’d like review, use the arrow keys to focus the document, and tap Enter to open it in the Diff View.
  • Use Ctrl+F8 to view the next difference and Ctrl+Shift+F8 to view the previous difference.
  • Learn how to set your own keyboard shortcuts in the One Step Further with Customization section below, to perform actions like staging your files.

Quickly Navigate to View your Repo Status

Whenever you want to checkout manage your branches, use shortcut Alt+G, M to navigate quickly to the Git Repository Window. Again, using Tab and the Up and Down Arrows. Additionally, Alt+UP/DOWN arrows will allow you to navigate between sections, including the:

  • Branches (the left side selector)
  • History (the right side list)
  • Commit Details (actions for the commit, commit message)
  • Commit Diff

Learn more at Browse repos, compare branches & commits on Microsoft Learn.

Switch Active Repositories

Image Repo Picker Shortcut

Back in the status bar, you can also use the shortcut Ctrl+Alt+F4 to open the Repository Picker which allows you to quickly switch active repositories, bringing up the Git Repository Window for review.

One Step Further with Customization

Take the next step towards keyboard mastery by assigning your own Keyboard menu of the Options dialog. Get there by typing “Keyboard” into the search bar. For example, you can stage files using the keyboard, by assigning shortcuts to these commands:

  • Git.Remove – Works as a toggle. If a staged file is focused, it will be unstaged. If an unstaged file is focused, it will be staged. The name is not super friendly, so we introduced the next two.
  • Git.Stage – Stages an unstaged file. Doesn’t work in reverse.
  • Git.Unstage – Unstages a staged file. Doesn’t work in reverse.

To see all of the commands for git, type “Git” into the “Show commands containing:” search.

Image Git Commands Keyboard Shortcuts

To learn more about how to customize key bindings checkout Identify and customize keyboard shortcuts.

Beyond Git Shortcuts

There’s a lot of content on Microsoft Learn to help you continue to make the most of the keyboard. You can start by checking out the most popular keyboard shortcuts for Visual Studio and dive deeper, including accessibility tips and tricks and learning how to use Visual Studio without a mouse. Find other productivity tips in the Productivity guide.

Thank You

Thanks for checking out ways to boost your productivity with Git keyboard shortcuts. Hopefully, these flows demonstrate how to make incorporating Git into your daily coding sessions easy and unobtrusive. If you have any feedback, use Developer Community to report an issue or Suggest a Feature for Visual Studio.

 

 

 

 

 

 

10 comments

Discussion is closed. Login to edit/delete existing comments.

  • Kristopher Wayton 2

    That’s’ helpful, thanks! I’ve been using WSL instead for editing with VI because I like using the mouse as little as possible. I wasn’t aware the key bindings were this flexible in Visual Studio, and I suppose also in VSCode.

  • Adin Aronson 0

    Git in VS is getting better and better! Please add an option to right click a previous commit and copy the comment to the clipboard or to paste it into the current commit comment box or any other way to easily get a previous commit comment into the current commit comment box.
    Cheers.

  • Patrick Szalapski 0

    I’m puzzled by “Ctrl+Alt, F3”. Don’t you mean Ctrl+Alt+F3?

    • Jessie HoughtonMicrosoft employee 1

      Thanks for catching that, it’s been fixed.

  • Jiří Zídek 0

    Ctrl+E, Ctrl+C is commenting current line in my VS 17.4.4

    • Jessie HoughtonMicrosoft employee 1

      Ctrl+K, Ctrl+C and Ctrl+K, Ctrl+U are the default mappings to comment and uncomment a line (respectively). You may have overridden the default mappings.

      • Eli Black 0

        Alternatively, I wonder if it’s because he’s using a non-English keyboard layout?

  • Emiliano Montesdeoca del Puerto 0

    Thanks for the post!

    I’m having some trouble running the Alt+G, C to go directly to write the git commit message, even tried to change it on the shortcuts manager.

    Here’s to screenshots, it doesn’t even display on the context menu:

    Screenshot 1
    Screenshot 2

    Thanks!

  • Pavel T 0

    Nice to see some improvements in this area, but VS Git integration is still miles behind Rider, including fast keyboard access to a lot more features. Hopefully VS team is taking notes.

  • Tobias Raphael Dieckmann 0

    I really look forward to some easy way to remove orphaned branches.
    Creating always new branches, that get deleted with the pull-request approval, requires here and there my time to delete them one after another.
    A one-click solutions would me more than welcome (and obviously VS knows, which branches are still connected to an remote branch indicated by that icon).

Feedback usabilla icon