Git And GitHub

Do you know someone developer, QA engineer, or DevOps who doesn’t use GitHub?

I like to share with you some information about GitHub and its useful features, also I will share some Git commands.

Let’s start 🙂

What is the GitHub?

GitHub is a platform, someone calls it a hosting platform, but it is not a hosting and it cannot host your website or web application.

GitHub profile

GitHub is a cloud-based platform where developers, QA engineer, and coders deploy their code. GitHub allows teams to collaborate on the project, update the code, and manage open source projects.
A lot of companies have their projects on this platform, it is safe and easy to use.

What is a Git?

Git is the version control system, it’s free and easy to learn its commands.

Why do we use it?
We are using it to track the changes in the files on the origin and to have fresh code over time in our local folders.

How to start with a git?

First, we need to create a repository. A repository is a remote directory where our code will be placed.

Go to the git and log in.

To create the git repository you’ll need to click on the + mark and select New repository like on the image below:

New repository

In a new window, we need to add a repository name and description. A repository name is required, but the description is not, it is optional.

Repository name

After these two steps, a button create repository will be enabled, click on it and we have a new repository created. What is next?

Now when we have a repository, it is only online, but not local. So we need to add it to our local environment to be able to push the future code on the git.

Create a local git repository

Firstly create a folder/repository on your machine where you want, this is not a strict location. You can choose where you want.

I usually do it with the terminal. In case you are using windows, you should download Git and install it.

The first command will be to create a folder of a local git repository:

your_location/ mkdir <foldername>

Then we have to initialize git in the early created folder:

cd <foldername>
git init
We will get a confirmation message that git is initialized.

Then we need to call or clone the git online repository to our local repository with the next command:

git remote add origin <link of a repository from the git>

The link is located like on the image:

After this command hit Enter and you will see that the git repository is cloned.
Now we have to do one more command to finish with the local git repository for now.

Run git pull origin <branch name>

The branch name of my repository is master

After the last step, you are successfully cloning a git repository, next is to add some code in the local git repository and push it to git.

Commands for pushing the code to the git remote repository will be available in the next post.

Thank you!

Leave a Comment

Your email address will not be published.