Git and GitHub have revolutionized the way Web Developers work.
Git is version control system. (Other version control systems are svn, mercurial, baazar, perforce etc.) So, Git is a tool using which you can version control the source code.
All the documentation on Git, you can find online at Git – Documentation. Basically, Git is a command line tool which runs on your local machine and allows you to track changes in source code while GitHub is a web-based Git repository hosting service.
It offers all of the functionalities of Git as well as has some amazing features of its own.
Currently, GitHub is the most popular code-hosting service among open source developers and programmers. It uses Git version control system, hence the name GitHub.
Github is not only used for programming and software development. It is also used by many other types of projects.
For example, it is used for Open Source Manuals, documentation projects, and other projects where users can collaborate online and work together
Why Should I Use GitHub?
Now let’s think of this scenario where you and your friend are good at programming – but mostly you have worked independently, on own systems.
One day, you got an interesting idea, you discuss with your friend and finalize to build it together.I’m assuming that you don’t know about Git.
So, naturally, you will be dividing the jobs – this one for you, that for me, etc. The first day was fine for both of you. You both try to merge the work. Oh! Did you face any problem? Probably you will.
Somehow, you manage to merge the works – but this will have to be done regularly. Once, it is merged you will have to test whether it is working or not. If not – again give extra time and work on it.
Now, one day your friend changed some of your codes – it might be needed. Now, after the merge – it is not working – frustrated – leave it – not my cup of tea.
Now let’s think of another scenario where you know about git.
Suppose, you started the task and pushed the progress to your repository (as a directory). Remember this as ‘your’ version of the project.
Your friend will get to see all the codes that you have written and changed. You have given him some tasks to do – which are independent of yours.
Once he pulled (fetched the updated work) add his work and again push it to the repository (It is common to both). Remember this as ‘his’ version of the project.
You can again check all the changes he did. If there is any conflict (You both edited the same page) – git will display them.
You can now correct it. Remember ‘his’ & ‘your’ version? If you think he has done some error, then you can revert back to ‘your’ version. Every ‘commit’ is saved as a different copy.
Some of the reason why Developers use GitHub
Collaboration made simple:-.A programmer uploads code to Git, where other developers can access it and edit it, isolated from each other and with all versions kept intact. Git takes away any confusion with having multiple people work on the same file at the same time.
Version control made easy:-Every time edits are made to the code, Git takes a snapshot. This tracks all the versions of a project along the way, saving a previous snapshot each time the file is saved in its “current state”—this is called a commit. Snapshots also let you revert back to old versions if something “breaks.”
Git has three main areas that are uniquely designed to give developers lots of control over workflow:
- A working directory, which contains current states of files. Numerous developers can access a directory when they’re logged in, so collaboration is easy.
- The staging area, which contains indexes of everything for the next commit, and any files that have been added or edited since the previous save.
- The Git repository, where new commits are added. A Git repository contains (a) all the metadata, (b) the files, and (c) a dedicated database that tracks versions of the project.
Branches are one of the most important parts of Git, and make collaborating and incrementally adding to code possible, and foolproof.
Developers and designers can work on the same project in an organized way—especially digital teams with remote freelancers.
In a branch, some or all of the code is isolated from the project so it can be worked on without affecting the master branch. That code can be experimented with and worked on, then either made into its own, new project or merged back into the original branch.
Getting Started With GitHub
Download git from Git – Downloads.
Sign up with Github – Build software better, together & create a repository. If you don’t know how then – ‘New Repository’ on the right side of the screen. Don’t get afraid if you see something like ‘license’, ‘gitignore’- if you don’t know about it don’t select. Post a question to know about them later.
I guess you have installed git without any problem. Now create a directory in your system. Say on D:/Github, give it a name and then right-click. Select ‘open Git bash here’.
Rember your GitHub username and the repository name? Now you are going to connect this directory in your system to the online repository you made. Follow this code.
$ git init
$ git remote add origin https://github.com/your_user_name/your_repository_name.git
Create a file README.md in this directory of your system. Open it and write something like below. Save it.
# Hello Github World – I’m a newbie.
Are you ready to push it online – in your repository? Follow the commands – and get used to them.
$ git add README.md
$ git commit -m “This is my first commit.”
$ git push origin master
Now, refresh your repository – and see the changes.Now I guess, you know the basic fundamental of git.
Some GitHub Terminologies
A repository (usually abbreviated to “repo”) is a location where all the files for a particular project are stored. Each project has its own repo, and you can access it with a unique URL
Forking a Repo
“Forking” is when you create a new project based off of another project that already exists. This is an amazing feature that vastly encourages the further development of programs and other projects.
If you find a project on GitHub that you’d like to contribute to, you can fork the repo, make the changes you’d like, and release the revised project as a new repo.
If the original repository that you forked to create your new project gets updated, you can easily add those updates to your current fork.
You’ve forked a repository, made a great revision to the project, and want it to be recognized by the original developers—maybe even included in the official project/repository.
You can do so by creating a pull request. The authors of the original repository can see your work, and then choose whether or not to accept it into the official project.
Whenever you issue a pull request, GitHub provides a perfect medium for you and the main project’s maintainer to communicate.
The social networking aspect of GitHub is probably its most powerful feature, allowing projects to grow more than just about any of the other features offered.
Each user on GitHub has their own profile that acts like a resume of sorts, showing your past work and contributions to other projects via pull requests.
Project revisions can be discussed publicly, so a mass of experts can contribute knowledge and collaborate to advance a project forward.
Before the advent of GitHub, developers interested in contributing to a project would usually need to find some means of contacting the authors—probably by email—and then convince them that they can be trusted and their contribution is legit.
When multiple people collaborate on a project, it’s hard to keep track revisions—who changed what, when, and where those files are stored. GitHub takes care of this problem by keeping track of all the changes that have been pushed to the repository.