8

I cloned a GIT repo in my device and started editing the code using VSCode. Then I made several changes to my code and committed it successfully.

But when I tried to push it from push menu it doesn't seem to be working. It shows that it's syncing, but that goes on forever.

I couldn't find any settings to configure credentials of git.

Sandun
  • 263
  • 1
  • 3
  • 15
Steve121
  • 129
  • 1
  • 1
  • 6
  • 8
    Possible duplicate of [How to do git push in Visual Studio Code?](https://stackoverflow.com/questions/29993599/how-to-do-git-push-in-visual-studio-code) – Alex Sep 12 '17 at 11:42
  • I had this same issue, rebooting fixed it for me. Also I've heard from VSCode GitHub forums that uninstalling git, rebooting, and then reinstalling git works. – jmbmage Dec 04 '18 at 14:50

4 Answers4

7

First of all check whether you have already configured GIT on environment variables. If so, simply run below commands on VS Code terminal

$>git --version 

Expected output

git version 2.28.0.windows.1

Use the command below to avoid prompt of git credentials every time and set it at global level

$>git config --global credential.helper wincred 

This will push your code to git repository

$>git push origin master

Try again, with push menu on VS Code.

Hope that helps !

Sandun
  • 263
  • 1
  • 3
  • 15
napster
  • 316
  • 2
  • 11
1

I was just experiencing something similar. Although the issue OP describes is the push continuing to sync but failing to connect, in what sounds like an initial commit. In my case it appeared as though all pushes were successful, in an existing repo/project where I've never had issues, nor had to do any initial git configurations inside VS... Things have always just worked, until the past few days, I just noticed none of my pushes actually made it to the repo.

But the title of the post is still relevant, so I'll answer in case it helps anyone else:

A simple VS Code update fixed my issue. While troubleshooting, I noticed a notification on the gear icon in the bottom left - which was an update ready to install. Once the update was installed and VS code restarted, I tried another pull, and then a push and everything's back to normal. Three commits finally found their way to the repo.

Chase
  • 1,724
  • 2
  • 18
  • 24
0

Try following steps

  1. reset your commit using- git reset HEAD~1
  2. take a pull - git pull

if the pull is unsuccessful then use - git stash

  1. commit your changes again
  2. Try to push your commit

Make sure you are connected to your git repository (any missing lan or wifi conenction)

Shubham Singh
  • 189
  • 13
0

I was having the same issue and was hoping to give a little more insight, as my vscode was stock and I ran into this problem right after cloning a repo. I would first recommend tig, as I was able to get more information on the problem rather than just try anything that came up on SO.

When I first used tig, I found that when I said commit with vscode via the check mark, it seemed to show up and have a commit, but didn't show up on GitHub.com. I then realized that vscode doesn't actually push the code with the check mark button, and you have to open a terminal either in vscode or the folder and actually git push origin main.

I recommend tig because in another similar problem I was pushing to different refs than main, which were only found with tig.

otsu
  • 449
  • 4
  • 12