Visual Studio Code – Connect to a remote Git repository and PUSH local files to a new remote repository

I assume you started to work in a directory and didn’t use Git there. The following should work with Git Bash:

cd "path to your repository"
git init
git add . # If you want to commit everything. Otherwise use .gitconfig files
git commit -m "initial commit" # If you change anything, you can add and commit again...

To add a remote, just do

git remote add origin https://...
git remote show origin # If everything is ok, you will see your remote
git push -u origin master # Assuming you are on the master branch.

The -u sets an upstream reference and Git knows from where to fetch/pull and where to push in the future.

Leave a Comment