If you are in windows use this line in your git bash:
git config --global credential.helper wincred
Next time git will remember your password. Thats all, the VSCode will work fine ;)
Bye Bytes !
Answer from Esteban Quintana on Stack OverflowIf you are in windows use this line in your git bash:
git config --global credential.helper wincred
Next time git will remember your password. Thats all, the VSCode will work fine ;)
Bye Bytes !
Tell Git your name so your commits will be properly labeled. Type everything after the $ here:
git config --global user.name "YOUR NAME"
Tell Git the email address that will be associated with your Git commits. The email you specify should be the same one found in your email settings on Github. To keep your email address hidden, see "Keeping your email address private".
git config --global user.email "YOUR EMAIL ADDRESS"
See this : Set Up Git
How to git push to a different branch with Visual Studio Code? - Stack Overflow
Shortcut to push code to git in VSCode? - Stack Overflow
git - Visual Studio Code push automatically - Stack Overflow
git - How to add a new project to Github using VS Code - Stack Overflow
Update 2022-12-27
On the Source Control tab (Ctrl+⇧+G or ^+⌘+G on Mac), press ⃛ to access Git commands dropdown menu:
Switch to the branch to push – Branch > Create Branch OR Checkout to... > ➕ Create New Branch

Press the Commit & Push button (if not visible, press ⌄ under the Message text box)
two popups will show up for you to confirm staging, committing and pushing of your changes to this new branch

Alternative using only menu options:
- Switch to the branch to push – Branch > Create Branch OR Checkout to... > ➕ Create New Branch
- Stage your changes – ➕ button above the files list OR Changes > Stage All Changes (several Git: options available)
- Commit your changes – ✓ top left button OR Commit
- Push the new branch: Branch > Publish Branch (or just use the Push option and press OK in the popup)
All above options can be accessed through commands F1 (Mac: fn+F1 or ⇧+⌘+P) and typing git [command], e.g. "git checkout".
For previous versions, check this answer's timeline.
git push an existing project to GitHub git init git add . git commit -m "Add existing project files to Git" git remote add origin https://github.com/cameronmcnz/example-website.git git push -u -f origin master
There is a button at the bottom left of the VS Code editor, which you can click to automatically sync your branch with that from remote (i.e. both pull AND push, merging your branch with upstream if necessary). This might or might not be what you want, but it's easy to click this when you know that there are no changes upstream (e.g. when you're working on a project by yourself).

Otherwise, I frequently bring up the Command Palette with ⇧⌘P (Ctrl-Shift-P on Windows/Linux) and type gpus, which brings up Git: Push as the first option. (It's been ingrained in my fingers since the days of Sublime Text)
If you are using the later versions of VS Code which has MRU list of command history, you can shorten it even further and just type gp, which is exactly what I've been using since SublimeGit in Sublime Text.

Lastly, another option you may want is to add a custom keyboard shortcut to push changes. You can do this by editing your Keyboard Shortcuts File, and adding something like the following:
{
{
"key": "ctrl+alt+p",
"command": "git.push"
}
}
There is a new setting Post Commit Command in vscode 1.30.1 to change the default commit behavior:

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.
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.
Here are the detailed steps needed to achieve this.
The existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.
Navigate to the local project directory and create a local git repository:
git initOnce that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI
git commit -am "Your comment"Now you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.
Copy the link to this newly created GitHub Repository.
Come back to the terminal in VS-CODE and type these commands in succession:
git remote add origin <Link to GitHub Repo>//maps the remote repo link to local git repogit remote -v//this is to verify the link to the remote repogit push -u origin master// pushes the commit-ed changes into the remote repo
Note: If it is the first time the local git account is trying to connect to GitHub, you may be required to enter credentials to GitHub in a separate window.
- You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
This feature was added in 1.45, demoed here.
Launch the command palette Ctrl+Shift+P, run Publish to Github, and follow the prompt. You will be given the choice between a private and public repository, so be careful that you choose the right one.

It may ask you to login to github. It will then prompt for the repo name (defaults to the name of the folder), and for creating a .gitignore file (defaults to empty .gitignore). Just hit enter if you are fine with the defaults. When you are done it should give you a popup notification in the bottom right with a link to the repo https://github.com/<username>/<reponame>
Minor warning: if your project already has a .gitignore file in it this process will overwrite it