How do I connect a local folder to an existing github repo?

Adding an existing project to GitHub using the command line:

# Initialize the local directory as a Git repository.
git init

# Add files
git add .

# Commit your changes
git commit -m "First commit"

# Add remote origin
git remote add origin <Remote repository URL>
# <Remote repository URL> looks like: https://github.com/user/repo.git

# Verifies the new remote URL
git remote -v

# Push your changes
git push origin master

And 2nd way as @evolutionxbox suggest you:

  • Clone git repo
  • Copy and paste into it
  • Push your change at origin

If in any case git reject your push you can use git push origin master --force

UPDATE (10-23-2020):
Bear in mind that since October 1st, 2020, Github renamed the default repository from master to main https://github.com/github/renaming

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)