Skip to content

Git hub repo from existing source

Humberto A Sanchez II edited this page Feb 8, 2023 · 3 revisions

Adding an existing project to GitHub using the command line

Follow these simple steps to add an existing project to Github.

Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

Initialize the local directory as a Git repository.

git init

Add the files in your new local repository. This stages them for the first commit.

git add .

or:

git add --all

Commit the files that you've staged in your local repository.

git commit -m 'First commit'

Copy the remote repository URL field from your GitHub repository it is in in the right sidebar.

In Terminal, add the URL for the remote repository where your local repostory will be pushed.

git remote add origin <_remote repository URL_>

Sets the new remote:

git remote -v

Push the changes in your local repository to GitHub.

Ignore woke instructions from git to create a “main” branch and use the following command:

git push origin master

The above pushes the changes in your local repository up to the remote repository you specified as the origin