Hands on Git Part-3

Lasith Jayalath
3 min readJun 2, 2019

--

This is my third article on Git. With this article I am looking forward to discuss about the concepts related to remote Git repositories. Until now I have explained how to install Git and some basic concepts associated with the local repositories with Hands on Git Part 1 and Hands on Git Part 2 respectively.

Remote Git Repository

Most of the version control related work (staging, commenting, status, log etc.) take place at the local repository. If you are the only individual who works with the project there is no need to setup a remote repository. But most of the time you have to work with a team. Therefor it is important to share data among the teammates. This is the place where the necessity of the remote repository concept arise.

With the remote repository concept, each developer will work in their local repository and they will push the code in to the remote repository. This will give other developers the chance to read and modify the code.

Basic flow of data in remote repository concept

You can create the remote repository at GitHub, GitLab, Bitbucket or at SourceForge. For this article I have selected GitHub.

Reasons for Selecting GitHub

It doesn’t have a history for acting in bad faith.

It is the largest community website for software development.

It contains the best tools for issue tracking, code review, continuous integration and for general code management.

Basics of GitHub

First create a GitHub account by visiting the GitHub home page.

Then navigate to Repositories and click New button to create a new Git repository.

Create new Git repository

Give a name which suites your project. I will create a remote repository with the name hands-on-git for the sample project I was discussing with the Hands on Git Part-2.

Naming the new repository

After creating the new repository it will direct you to a page which contains the repository URL.

Repository URL

Now you have to point your local repository to the created remote repository. Issue the bellow command on the terminal, in the directory where your local repository is stored at.

git remote add origin [repository url]

Git Push

In the sample example explained with Hands on Git Part -2 there is committed code available at the local Git repository. In order add that code to the remote repository, Git Push command is used.

This command will add the code from master branch of the local repository to master branch of the remote repository.

git push -u origin master

Git Pull

As we all know the remote repository code is also been updated by the developers continuously. Therefor it is important to get the latest changes from the remote repository to the local repository. In order to assist that Git Pull command is used.

git pull origin master

Git Clone

Sometimes when you are joining an already existing project it is important get the already available project. In order to perform that task git clone command is used. This command will help to download an existing remote repository in to your computer.

git clone [repository url]

With this article I have discussed the most basic concepts related to remote repositories. With the next article I will explain about Git branching.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Lasith Jayalath
Lasith Jayalath

Written by Lasith Jayalath

Developer | Cambio | Ex WSO2 | Faculty of Information Technology | University of Moratuwa| Richmondite

No responses yet

Write a response