GitHub is about code, commits and collaboration. Millions of bussinesses and organizations use GitHub.
Lets highlight the features of GitHub which made it so special.
What exactly is GitHub?
GitHub is a hosting service for Git repositories with its own features.
Repository is nothing but the space where your code resieds in.
Git is a version control system that allows to manage the history of your files, especially source code of computer programs.
Git was started by Linus Torvalds, The creator of Linux
Version control –
When developers write code they constantly make changes in the files. They need to keep the track of how the code changes over time. So that if something wrong happens with their currently working code they can easily go back to the working copy of code. Git allows you to revert back anytime to any version of your code.
Distributed repository model –
In centralized version control tools like Apache Subversion(SVN), Concurrent Version Systems(CVS), there is a single copy of the project maintained on central server.
Centralized version control system(CVCS) uses a central server to store all files and collaborates with other team members. Programmers comitt their code directly to the central copy. Other programmers can then see these changes. They can also update their code with the latest changes. But the major drawback of CVCS is its single point of failure. If the central server goes down or crashes then during that time, no one can collaborate at all.
In this case, Distributed version control system(DVCS ) proves useful.
Git is Distributed version control system (DVCS)
Distributed structure of Git provides a local repository and full history of the project on local machine of each developer. User does not need to connect remote repository everytime.
User gets full backup of the repository everytime he fetches the origin. As Git does not depend upon the central server, user can access the code though there is no Internet connection. User can create branches, commit changes, view history when he is offline. Internet connection is required only to publish your changes and update your repository with the latest code.
If the server goes down, then the repository from any user can be copied back to the server to restore it.
Publish the code –
Along with version management feature, GitHub allows developers to publish their code as well. It is a good option to upload your code and projects in the repositories of GitHub. This helps other programmers to know which projects or languages you are working on.
The code on GitHub is public. But if you want to keep your sensitive projects private then you can use private repositories of GitHub which are available with various paid plans
How to use the Git?
There are many different ways to access Git repositories.
Using terminal and commands or through GUI based applications you can push and pull the code. As compared to terminal, GUI based applications are quite easier and user friendly to use
GitHub Desktop is one of the simple, easy GUI based applications that helps user to create account on Git and use Git repositories. Performing operations like creating repository, committing the code, branching, merging, publishing your code on GitHub, fetching code again, cloning the repository have become much easier with GitHub Desktop tool
To use Git we will be using the GitHub Desktop.
Follow the steps below to use Git –
Step 1: Install Git and create a GitHub account.
An easy way to get Git installed is by installing GitHub Desktop
Step 2: Create a local Git repository.
Add repository name,description and local path.
Step 3: Add new files to your repository.
You can add new files to your project where you have saved the project.
Step 4: Commit the code.
Once you add new file or make changes to your file, Git notices these changes and shows these changes under column Changes.
There is commit button to commit the changes done in the repository. You need to add summary and description to maintain history of changes and commits.
Step 5: Create a branch.
Branches are created to maintain different versions of your code. If you want to implement new feature in your project but at same time want to keep existing code as it is, you can.
Select option Branch -> New branch to create a branch.
Step 6 : Merge the code.
Once you complete implementation and testing of new feature and if it works fine then you can merge it with main code. This will keep your main code updated. Merging is now very easy with GitHub Desktop.
Select option Branch -> Merge into current branch….
As shown in the image it will ask which branch you wish to merge.
Step 7 : Publish repository.
Publishing your code on GitHub is making your code available for other programmers.
Now other programmers can see your published code. If they want to make changes or improvements in your code they can send request to you to accept those changes. If you want to add those changes to the project you can merge their code with yours. After merging the code in GitHub repository you can fetch those changes to your local repository.
Now you know that GitHub does not only maintain different versions of your code but also provides various features like branching, merging, pulbishing your code, collaboration with other developers and fetching modified code back to local system.
So Sign Up for free GitHub account and enjoy GitHub features with your team.
References :
1. https://www.tutorialspoint.com
2.https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners