Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code push automatically

Is it possible to make git push after commit automatically? Now I need to click on push after commit manually and this is not very comfortable.

like image 498
kagarlickij Avatar asked Jan 11 '16 10:01

kagarlickij


People also ask

How do I push changes in Visual Studio Code?

As you do your work, Visual Studio keeps track of the file changes to your project in the Changes section of the Git Changes window. To stage changes when you're ready, select the + (plus) button on each file you want to stage, or right-click a file and then select Stage.

How do you commit code in VS Code?

You can type a commit message above the changes and press Ctrl+Enter (macOS: ⌘+Enter) to commit them. If there are any staged changes, only those changes will be committed.


2 Answers

Visual Studio Code has a setting to push or sync on commit.

  • Go to the VS Code Settings menu (Gear on the bottom left > Settings)
  • Go to Extensions > Git and look for Post Commit Command
  • One of the options is push (the other is sync). Choose that.
like image 129
Josh Unger Avatar answered Oct 06 '22 23:10

Josh Unger


I use Gitlens extension to make it easier to push commits.

  1. Install Gitlens extension.
  2. Go to Settings -> Extensions -> Git -> Post Commit Command, choose "push" from dropdown.
  3. Make some changes in your code.
  4. Head to gitlens tab, add a commit comment, stage the changes and hit "Commit" (tick sign). The post commit command will take care of the rest.

That is it. It is simple, very fast to use and you don't need CLI at all.

like image 24
voider Avatar answered Oct 07 '22 01:10

voider