Site icon CodeARIV

Adding an Existing Project to GitHub or Bitbucket

Image is loading...

There are lots of hosting service providers for version control using Git such as Github, Bitbucket, Gitlab, Sourceforge, Launchpad, etc. But Here I am only explaining two of them. Github and Bitbucket.

GitHub Inc. is a web-based hosting service for version control using Git. It is mostly used for computer code. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features.

GitHub brings together the world’s largest community of developers to discover, share, and build better software. From open source projects to private teams. It is commonly used to host open-source software projects.

Now coming to Bitbucket, it is also a web-based version control repository hosting service owned by Atlassian, for source code and development projects that use Git revision control systems.

The main advantage of Bitbucket over GitHub is, it integrates with other Atlassian software like Jira, HipChat, Confluence, and Bamboo.

Prerequisites

Before continuing this article, I assume that you have basic knowledge of Git, GitHub, and Bitbucket. You also need to have a project to add on GitHub or Bitbucket.

What we will learn

In this article, we will learn to install Git on our operating system and add our project to GitHub or Bitbucket.

Before adding the project to GitHub or Bitbucket

Before trying to add our project to GitHub or Bitbucket, we need to globally install Git on our system. The installation procedure of Git is explained below.

Install Git on Ubuntu or Debian

In Ubuntu or Debian-based systems, Git can be downloaded easily using Advanced Package Tool (APT). The below command installs Git on our system.

sudo apt-get install git

Install Git on Fedora or Redhat

We can install Git on Fedora/Red Hat-based systems using the yum tool. The below command installs Git on our system.

sudo yum install git

Install Git on MacOS

We can simply download .dmg installer file for macOS from the below URL and can be installed.

https://git-scm.com/download/mac

Install Git on Windows

If we are using Windows OS, direct to the below URL and we can get a .exe file which is the default installation file in Windows.

https://git-scm.com/download/win

Add our project to GitHub

I am going to explain the steps in adding a project to the remote repository on GitHub.

We need to register for an account in GitHub first. Then go to the URL below.

https://github.com/new

Enter a repository name and description as in the snippet below.

This will lead us to a page like below which contains the remote repository URL and all the commands to push our project to the repository we created.

First, we have to initialize our project directory as a local repository by running the below command from the root directory of our project.

git init

Now add all the files and folders under our project directory to git.

git add .

We need to commit these changes.

git commit -m "Initial commit"

After that, set the remote repository URL to the project directory(local repository).

git remote add origin [your_remote_repository_url]

Now push all files to the remote repository. The below command pushes our project to a master branch in our remote repository.

git push -u origin master

Add the project to Bitbucket

After creating an account in Bitbucket, direct to the below URL to create a new remote repository.

https://bitbucket.org/repo/create

This will lead us to a new page as below. From here we get the URL of our remote repository and instructions to push our project to it.

First, we have to initialize our project directory as a local repository by running the below command from the root directory of our project.

git init

Now add all the files and folders under our project directory to git.

git add .

We need to commit these changes.

git commit -m "Initial commit"

After that, set the remote repository URL to the project directory(local repository).

git remote add origin [your_remote_repository_url]

Now push all files to the remote repository. The below command pushes our project to a master branch in our remote repository.

git push -u origin master

If you are willing to learn the complete guide on Git, take a look at the tutorial. Git – A Beginner’s Guide with Commands and Operations

Summary

So here in this article, we learned the steps to add a project in GitHub or Bitbucket. This will make your project safe in trackable in a remote Git repository.

Exit mobile version