4

Is it possible to automatically git push when I make a commit in Visual Studio 2022? I see the Commit All button by default, and I don't want to have to click the arrow beside it every time that I want to commit & push at the same time, which is the action I always do when I commit.

Visual Studio Code has a nice setting for this, but I didn't see a similar settings to configure it in Visual Studio.

3
  • 3
    I do not think you will find stuff like that anywhere out-of-the-box because one of the tenets of DVCS is to be able to keep your stuff private. If it's such a pain for you, you might want to develop a git alias (or a plugin/extension.... those are also fancy) or a full-blown script that does commit/push in a single action.... considering how often I do git commit --amend after committing, I wonder if this is a good idea overall but..... Commented Jun 17, 2023 at 7:24
  • @eftshift0 Eclipse offers dedicated Commit and push button out of box Very convenient Commented Jun 17, 2023 at 8:29
  • @eftshift0 I review the diff of each file before I commit, and that helps me to avoid having to amend. Vsc and vs both have a nice looking diff built-in. Commented Jun 17, 2023 at 13:17

1 Answer 1

3

You can assign a keyboard shortcut to perform the commit and push instead of just commit.

Go to Tools → Options → Environment → Keyboard and optionally search the word "commit". Find the Team.Git.CommitAndPush shortcut and set it to what you wish. In this case, I remapped Team.Git.Commit (normally Ctrl + Enter) to Team.Git.CommitAndPush. When assigning the shortcut, be sure to select "Git" for the "use new shortcut in" drop down.

keyboard shortcut to set commit and push

After changing this, you can see that the drop down option now has the shortcut too:

commit and push drop down option with shortcut keys listed

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.