Visual Studio Code push automatically

GitPushVisual Studio-Code

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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.

Solution 3 - Git

There doesn't seem to be something like that built-in to VSCode's Git front-end, but there is an option to remove the safety check. "git.confirmSync": false will remove the confirmation dialog when using VSCode's built-in Push/remote sync.

@Mistermatt's link looks like what you asked for though, I've had too many problems with blindly pushing myself :).

Solution 4 - Git

i would use .bashrc function eg. gitall
add steps if needed post push

eg.

function gitall() {  
    file=${1:-.}  
    comment=${2:-update}  
    echo $file  
    echo $comment
    git add $file && git commit -m '$comment' && git push origin master
    ssh user@host "bash /commands.sh"
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkagarlickijView Question on Stackoverflow
Solution 1 - GitJosh UngerView Answer on Stackoverflow
Solution 2 - GitvoiderView Answer on Stackoverflow
Solution 3 - GitwgjView Answer on Stackoverflow
Solution 4 - GitebriccaView Answer on Stackoverflow