Git and GitHub for Beginners #1
What is Git and GitHub? -An Introduction
Imagine you are working on a project. After completion of your project, you convert it into a zip folder and save it as “project.zip”. Now after few days, you make some edit in your project and thinking that it is the final version you save another folder as “finalProject.zip”. But what you thought was not final!!! You again had to edit something and hence you had to again save another zip folder for your project even though you might have just edited just two lines of code in your project!
This is where git comes into use. Git is a version control system. It helps to keep the record of every version of your project. Advantages of Git include:
- Easy recovery of files: Git allows you to recover the files which you might have accidentally deleted while working on new version of your project.
- Who introduced what changes in code: Suppose you are working in a team project and someone commits some changes to your code which causes an issue or bug in your project, then you can easily see which team member of yours has done it. The team collaboration will become more clear when we discuss about GitHub.
- Rollback to any previous state of code: Git allows you to roll back to any previous state of code which you might need at any point of time.
Now let us take a look at GitHub.
GitHub is a website that hosts the git repositories. It helps us in collaborative work. GitHub allows us to work as a team.
We can create a git repository on GitHub or even link a repository from our local machine to GitHub. Now our project is available on a server and anyone can access it.
Suppose there is a team of three people… A, B and C. Suppose A creates a repository and pushes it to GitHub. Now B can pull that repository on his local machine, commit changes and again push them on GitHub. Similarly, C can also do the same. Thus, GitHub allows us to work collaboratively as a team. Also, we can contribute to project of some other user by creating a pull request to him/her. In this case, changes are not directly committed to a repository and the owner can review the code and merge the pull request if it seems fit.
At the same time, the git repository keeps a track of all the commits performed by different users, and thus helps in resolving debates regarding from where some bug has come to the code.
Thanks for reading :)
I will continue this series on Git and GitHub in my next blog. Meanwhile, do comment your views.