Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code how to use github with existing local project

Tags:

github

I have a local project in C:\ABC folder, just realize it's time to back it up to GitHub. This is what I did:

  1. Log on to GitHub, created a new project (repository or whatever you can call).
  2. Copy the URL.
  3. Back to VS Code, install GitHub extension.
  4. Go Welcome page, click on "Clone Git repository...". Paste the URL for "Repository URL". Enter my local path C:\ABC, .

Error Git: fatal: destination path "C:\ABC" already exists and is not an empty directory.

I understand it tried to fetch from GitHub to local, but what I want is the opposite. Googled found many articles and video on how to do from scratch, but not for existing local project.

Update of 2021-08,

see my latest step-by-step solution

like image 477
Jeb50 Avatar asked Aug 26 '17 01:08

Jeb50


1 Answers

Try instead with command-line:

cd c:\ABC
git init .
git config --global user.name <yourGitHubAccount>
git config --global user.email <yourGitHubEmailAccount>
git add .

git status
# edit .gitignore to ignore folder you don't want

git commit -m "first commit"
git remote add origin https://github.com/<yourGitHubAccount>/<yourRepo.git>
git push -u origin master

Make sure your GitHub repo was actually empty (no README.md)

like image 197
VonC Avatar answered Jan 08 '23 00:01

VonC