Home / Software Engineering / Code Management / GIT / How to upload a new project to a remote Git repository

How to upload a new project to a remote Git repository

Print Friendly, PDF & Email

I often forget how to upload a new project to a remote Git repository because that is rarely done. Thus I need to summarise essential steps of this operation in my blog so that I could have look it back. So here is how you can also do it.

  1. First create a remote Git repository in your GitHub or Bitbucket account. You can create a repository in GitHub from the link, or in Bitbucket from the link (remember logging in before clicking these links).
    Create a new repository in GitHub

    Create a new repository in GitHub

    Create a new repository in Bitbucket

    Create a new repository in Bitbucket

  2. After creating a remote repository, copy the clone URL. This would look something like:
    • git@github.com:<username>/<project-name>.git  (based on GitHub) or git@bitbucket.org:<username>/<project-name>.git (based on Bitbucket), if you decide to use SSH port.
    • https://github.com/<username>/<project-name>.git  (based on GitHub) or https://<username>@bitbucket.org/<project-name>.git  (based on Bitbucket).git, if you decide to use HTTPS port.

    See here for GitHub and there for Bitbucket if you need more help.

  3. Next go to the local directory where you have created your project and run the command git init . This would make your project being tracked by git.
  4. In addition, you have to map the newly created Git repository in your local directory to the GitHub/Bitbucket remote repository.
    git remote add origin [alias-for-this-url] <the-clone-URL-as-described-in-the-step-2> .
  5. Finally, you can make some modifications, add these changes and push them your remote repository.

That’s it. To test the mapping, type the command  git remote -v . This should list your remote repository URLs.

The result of running the command git remote -v

The result of running the command git remote -v

Notes:
We often encounter a “Permission denied” error, while trying to do a git push , it means that, the server has rejected your connection. To fix this you will have to add your ssh key to your GitHub account. The steps for adding the ssh keys are well explained here or there.

comments

About Nguyen Vu Ngoc Tung

I love making new professional acquaintances. Don't hesitate to contact me via nguyenvungoctung@gmail.com if you want to talk about information technology, education, and research on complex networks analysis (i.e., metabolic networks analysis), data analysis, and applications of graph theory. Specialties: researching and proposing innovative business approaches to organizations, evaluating and consulting about usability engineering, training and employee development, web technologies, software architecture.