GitHub is a web and cloud-based platform that helps users to store and manage their code. Git is a version control system that tracks changes to files and allows multiple people to collaborate on the same project.
What exactly is GitHub?
To be very crunch “It is a file or code-sharing service to collaborate with different people”.
GitHub is a widely used tool for version control. It is helpful when more than one person is working on a project. For E.g., a software developer team wants to build a website, and everyone has to update their codes simultaneously while working on the project. Here, GitHub helps them to build a centralized repository where everyone can upload, edit, and manage the code files.
Why is GitHub so popular?
It has more advantages, but many users have doubt as why not use ‘Drop box or any cloud’ based system? For E.g., More than two users are working on the same file, and they want to update it at the same time. If a person who save the file first will get precedence over the others. While in GitHub, its document the changes and reflect them in an organized manner to avoid any disorder between the files uploaded.
Hence using GitHub centralized repository, it avoids all the confusion and working on the same code becomes very easy.
Some key concepts in GitHub
1. Creation of the repository:
A repository is a collection of files and their associated revision history. Each repository has a unique name and is stored in a directory on the Git server.
These simple steps to create a GitHub repository:
- Go to the link: https://github.com/ . Fill the sign-up form and click on “Sign up for GitHub”.
- Click on “Start a new project”.
- From the main page, click the New Repository button.
- In the Create a new repository window, type the Repository name of the repository you want to create with a description.
- Enter a Description.
- Select either Public or Private depending on how you want to share the repository.
- If you want the repository cloned to your computer, select the option to Initialize the repository with a README.
- Finally, click the Create repository button.
Once the GitHub repository is created, you and anyone else with access can access the repository with Git.
2. Creation of a Branch:
Branches help you to work on different versions of a repository at one time. By default, every repository has a main branch called “Master.” You can create additional branches to work on new features or bug fixes without affecting the main branch.
To create a branch in GitHub, follow the below steps:
- Click On GitHub.com, navigate to the main page of the repository
- Click on the dropdown “Branch: master”
- Click New branch.
- In the dialog box, enter the branch name and optionally change the branch source. If the repository is a fork, you also have the option to select the upstream repository as the branch source
- Click Create branch.
3. Changes commit to the branch:
A commit is a snapshot of the changes made to a repository. When you make changes to a file and commit those changes, you create a new revision in the repository’s history.
Let’s make our first commit, follow the below steps:
- Click on “readme- changes” file which we have just created.
- Click on the “edit” or a pencil icon in the rightmost corner of the file.
- Once you click on that, an editor will open where you can type in the changes or anything.
- Write a commit message which identifies your changes.
- Click commit changes in the end.
4. Merge:
Once you finished working on a branch and want to incorporate your changes into the main branch, you can perform a merge. This combines the changes from the branch with the main branch and creates a new commit in the process.
5. Pull request:
A pull request is a request to merge one branch into another. When you create a pull request, you can discuss the changes with other team members and get feedback before merging the changes into the main branch.
How to Automatically Merge a Branch’s Pull Requests?
Follow the steps below,
- Navigate to the Setting tab under the main page of your repository.
- Under the Options tab, scroll down to find and “enable the Allow auto-merge” button under the Merge button section.
Git and GitHub provide fast and convenient ways to track projects, whether the project is by one individual or a team of software developers. Although GitHub has many complex features available, it’s easily accessible for individual and small projects that need some kind of tracking mechanism.