Basics of git and GitHub and Git Commands

basics-of-git-and-github

Basics of git and GitHub Intro:

In this article, We are going to discuss the basics of git and GitHub. We will look into the simple git workflow. We will start by installing the git and then look at how to check out the code or create a new repository. Then we learn about git commit and the git push commands.

What is Git :

Git is a version control system (VCS) that is used for software development and other version control tasks

Installing Git :

on ubuntu :

apt-get install git

on centOS :

yum install git

Creating the Repository :

First of all, create a folder for the project. Then we need to initiate the git local repository.

mkdir testRepo
cd testRepo
git init

git init will create one local git repository and adds a few files like .git and .gitignore.

After initializing the git it’s time to add some files to our project in my case testRepo

echo “This is git ReadMe file.” > Readme

Now let’s try to commit this Readme file to the local git repository. To do that, first of all, we need to add it using the following command

git add Readme or git add –all

Then you can see the status of the git at any time using the git status command

git status.

To commit the latest changes to the git local repository. Use the following command,

git commit -m ” Initial Release “

Now all the changes you made after creating the Git project are saved in the git local repository.

Pushing Code to the online repository using git push:

You can also make these changes available online by pushing these changes in any of your GitHub accounts. like GitHub or bitbucket.

So to push these changes to your cloud accounts or remote accounts. Use the git push command like below

Before pushing any code, first of all, specify your online GitHub link.

git remote add origin https://github.com/mvenkatesh431/webrtc.git

Now you specified your remote git account link. Now you need to push testRepo code to the GitHub repo using the git push command

git push -u origin master

This git push will push the local repository into the online repository. Now you can use the code from anywhere and you can give access to these repositories to your friends and colleagues.

That’s it. These are the very basic things about git.

References:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. Daria Johnson says:

    Great article, Venkatesh!
    So easy to understand. Do you plan the next chapter?

  1. […] Look at the following post for Introduction to Git  […]

Leave a Reply