How to Use Command Line to add an Existing Project in GitHub?

There are lots of ways you can share and collaborate using your existing work on GitHub.

Note: You can also use GitHub Desktop to add your project if you want to work with a point-and-click user interface. However, it is not suggested storing business-critical or sensitive information like PIN, Passwords, API Keys, etc. in a remote repository.

  1. Go to GitHub and create a new repository.GitHub Repository

Do not use README or license files to initialize the new repository. These files can be added later after loading the project to GitHub.

  1. Open Git Bash.
  2. Make your local project as your current working directory.
  3. Initialize your local directory using the following command.
   $ git init
  1. Add the files in your local repository using the following command.
      $ git add

The command stages the added file for commit. You can use the ‘git reset HEAD yourfile’ to unstage a file.

  1. Commit the files from local repository using the following command.
$ git commit –m ‘First commit’

This command commits the changes and prepares them to be pushed on the remote repository. You can use the ‘git reset –soft HEAD~1’ command to modify the file.

  1. Copy the remote repository URL from your GitHub page.Remote Repository URL
  2. Go to the command prompt and add the remote repository URL where your local repository will be pushed. This can be done using the following command.
 $ git remote add origin remote repository URL

This sets the new remote

 $ git remote –v

This verifies the URL

  1. Push the changes to GitHub.
$ git push origin master

This pushes the changes in local repository to GitHub.

You may also like: How to Open a GitHub Project Using Visual Studio?

 

SHARE THIS

Get A Free Quote