Basic Git/GitHub commands

Default featured post

Simply GitHub can be defined as a web-based hosting service which is used for software development project especially Free and Open source projects. In other words, GitHub is like a host for software projects that allows various development teams or company upload their project their and ask their developers to put their updates work. It is derived from Git (kind of revision control) which is developed by Linus Torvalds (Linux kernel creator) and his colleges.

Git(Hub) allows programmers to work on a project at the same time together and update their code and get the last update from their peer programmers.

Obviously, it makes development project lot easier and centralizes the project as well. Additionally, Git(Hub) gives this advantage to developers to work together from far distance. For instance, imagine that a programmer from London, UK works on a project, meanwhile, another programmer from California, US works on the same project.

Furthermore, this fact can help to 24 hours software development. It means that bunch of programmers in a country do programming and testing is done in another country with around 9 to 12 hours difference in time zone. For instance, imagine that coding part is done by programmers in US in working hours and at (US) night debugging part is done by testers in India since in India it is morning and working hours.

Basic Git/GitHub commands

Git is available for Linux, Mac, and Windows. For downloading different Git software please click here.
The aim of this section is to show how to work with Git in text-mode. Therefore, it is assumed that you already create your account and repository. For know how to create GitHub account and know how to create repository click here and here. For installing and setting up GitHub in Linux console read this article.
For starting Git open terminal application and go to your project folder and type following line,

$ git init

Mentioned command add .git folder into your project folder. This folder contains needed files for GitHub, so, do not remove or manipulate its files.
For knowing the current status of Git type following command,

$ git status

If any new changes have been done in the project folder the status shows changes and comment you to apply new changes.
For adding new file type,

$ git add [file name(s)]

For committing your added file type,

$ git commit -m "Message"

In order to connect to your Git account type,

$ git remote add origin [Your GitHub project link]

For example,

$ git remote add origin https://github.com/kasramp/HelloWorld

For apply your changes and upload them to GitHub host type following command,

$ git push -u origin master

Here master means that you are creator of repository (project) if you are not creator of the repo this command will not work and you should firstly, Fork a project and after applying changes push it to master to add new changes to project. This area will be covered in another post.
In order to get latest changes by your peer programmers you need to pull new changes with below command,

$ git pull origin master

To get log of your commits type,

$ git log

In the next post more Git commands will be discussed. For working with Git without creating account and on the condition that Linux is not installed on your machine, this website is really good online tool for learning with simulating command line.