GitHub is a very popular development platform used by almost 50 million developers around the globe to host and review code, manage projects and build beautiful software. GitHub has DevOps-related features in it, which makes it a favorite option for organizations to work on their private and public projects. Software developers use GitHub to make things, enhance existing projects.
Git and GitHub
Git is a version control system i.e. it tracks changes to the files. Git helps you in having logs of who, when, what, and if the available why the changes were made to your file. It also helps you to go back to any version of your file, it is just like undo/redo feature. You can hop between the different versions of your files just using Git commands. Git helps you to take a snapshot of your file i.e. to create a version of your file. Git does everything locally on your machine. GitHub is a cloud-based platform that has Git as its underlying technology. It helps developers to collaborate remotely. GitHub is a remote repository for Git. GitHub is having some more features, that is you can create issues, have discussions, create pull requests, you can fork projects, etc.
Branches
Branches in Git, are kind of the same as branches in a tree, a tree branch is sourced from the trunk and can be many, can fall, flourish but the trunk has to be there. Similarly, the master or default branch is like the trunk of the tree. Changes you make in a branch do not affect another branch, hence the branch is used to test and create new features, once you are satisfied with the working and behavior of the branch you merge it with the master branch by getting it reviewed (by creating a Pull Request). The master branch is supposed to be always production-ready and deployable to the production environment.
####Commits Commit is just like saving the file in the branch. Whenever the commit is made, it saves some information about time and contributors. This helps anyone to review the files, to get information about the changes to the file when it was done who did it.
Pull Request (Merge Request)
Pull Request is the way to tell the maintainer of the project to review the branch and merge it into the master branch. The requester can add reviewers if needed and get their comments on it. The reviewers have options to decline the Pull Request or ask the requester to verify the work or even can merge into a master branch with suggestions, or simply pass comments without merging and declining it so that it can be discussed with another reviewer. Once the PR has been approved, the pull request’s source branch may be merged into the master branch.
Labels
Labels help collaborators to organize and categorize pull requests, issues, and discussions. In GitHub, you get a lot of labels out of the box and even you can create one if needed. Examples of Labels include bug, documentation, duplicate, help wanted, enhancement, question, ready to pick.
Cloning and Forking
Cloning is getting a copy of the repository with its history on your local machine, and if you have permission you can push your changes to the remote repository as they get completed. Forking a repository is creating a clone of the repository in your GitHub account, here the forked project becomes the remote repository and the source repository becomes the upstream project. If you have the write access to the GitHub repository, it’s better to clone the repository on your local machine, do the changes and push it to the remote repository. However, if the repository is owned by someone and you don’t have permission to write on it, do a fork of it and then clone the forked repository on your local machine. The changes made to your forked repository can be proposed to merge into the upstream project by creating a Pull Request.
GitHub Pages
GitHub has a hosting engine to host static websites. Using GitHub Pages, you can host your website on the github.io domain. To use this feature you’ll have to follow some conventions and enable some features, and then you can host your own HTML files. To read more and learn about GitHub you can go here.