Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have created a local project with Visual Studio Code that implements a local Git repository.

Then I have create a Git repository on Visual Studio Online and I want to push all my project files to the remote repository...

What is the correct procedure to do it?

My .git\config files at this moment look like this:

[core]     repositoryformatversion = 0     filemode = true     bare = false     logallrefupdates = true     ignorecase = true     precomposeunicode = true 
like image 342
DarioN1 Avatar asked Apr 12 '17 08:04

DarioN1


People also ask

How do I push code to existing GitHub repository from Visual Studio Code?

To push the code to GitHub from Visual Studio Code, you will need to create a GitHub account and install the “Github Pull Requests and Issues” extension. Note: Before pushing the code from VS Code to GitHub, you need to ensure that all the files are in one folder, and you have to push your folder to Github.

How do I change my Git repository code in Visual Studio?

Select one of your repositories, and then select the repository location, which must be a folder. Once you choose the folder, you click the Select Repository Location button. After this, we need to set the Git username and email address with the git config command on the terminal.


1 Answers

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.

like image 91
Christoph Avatar answered Sep 27 '22 20:09

Christoph