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.
Asked
Active
Viewed 3.8k times
71
-
Not yet, still searching for solution and using CLI to push changes – kagarlickij Dec 04 '16 at 12:22
-
1Maybe this answer can solve your problem http://stackoverflow.com/a/7925891/5571277 – Mistermatt Mar 20 '17 at 15:36
-
Possible duplicate of [How to automatically push after committing in git?](https://stackoverflow.com/questions/7925850/how-to-automatically-push-after-committing-in-git) – Matthias Fischer Dec 12 '17 at 13:19
-
1Separate `commit` and `push` is one of the features that makes Git better than Subversion. Don't drop it out. – axiac Dec 20 '18 at 13:06
4 Answers
110
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 Settings > Git and look for Post Commit Command
- One of the options is push (the other is sync). Choose that.

Community
- 1
- 1

Josh Unger
- 6,717
- 6
- 33
- 55
9
I use Gitlens extension to make it easier to push commits.
- Install Gitlens extension.
- Go to Settings -> Extensions -> Git -> Post Commit Command, choose "push" from dropdown.
- Make some changes in your code.
- 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.

voider
- 91
- 1
- 2
0
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 :).

wgj
- 18,876
- 1
- 17
- 26
0
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"
}

ebricca
- 386
- 3
- 5