Keyboard Shortcuts to Master Your Git Flow in Visual Studio
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.
|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
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
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.
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.
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.