Basics of git and github | Introduction to git and basic git commands to maintain a repository.

Spread the love

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 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 git status command

git status.

To commit the latest changes to git local repository. Use 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 git push command like below
Before pushing any code, first of all, specify your online GitHub link.

git remote add origin

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

git push -u origin master

This git push will push the local repository into the online repository. Now you can use these code from anywhere and you can give access to these repository to your friends and colleagues.
That’s it. These are the very basic things about git.

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

2 Responses

  1. Daria Johnson says:

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

  1. March 3, 2017

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

Leave a Reply