In one git repository (workspace), I want every save committed ASAP. What is the easiest way to achieve that with VSCode?
So, when I press CTRL + S, it gets pushed upstream.
This can be done with plugin Run on Save
Here is the example that auto commits and pushes upstream any changes in the directory mydir
:
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\\\mydir\\\\",
"isAsync": false,
"cmd": "cd ${fileDirname}",
},
{
"match": "\\\\mydir\\\\",
"isAsync": false,
"cmd": "git add -A",
},
{
"match": "\\\\mydir\\\\",
"isAsync": false,
"cmd": "git commit -a -m \"vscode autosave\"",
},
{
"match": "\\\\mydir\\\\",
"isAsync": false,
"cmd": "git push",
}
]
}
One way to achieve that is via terminal on VSCode. Change to the topmost directory containing the .git file and run the following commands:
git status
This shall show you the uncommitted changes. Then run the following for the new added changes (except for the remove changes)
git add <fileName>
This shall add all the added contents to index. Run below for the remove changes.
git rm <filename>
Then, git commit -m <commit msg>
to commit the changes.