Getting Started With GitHub
Table of Contents
Github is an online platform built to promote code hosting, version control and collaboration among individuals working on a common project. Projects can be handled from anywhere through the platform. (Hosting and reviewing code, managing projects, and building software with other developers around the world) The GitHub platform offers project handling to both open-source and private projects.
Features offered in regards to team project handling include; GitHub Flow and GitHub Pages. These functions make it easy for teams with regular deployments to in handling the workflow. GitHub pages, on the other hand, provides a place for showcasing open source projects, displaying resumes, hosting blogs among others.
Individual projects can also be easily handled with the aid of GitHub as it provides essential tools for projects handling. It also makes it easier to share one’s project with the world.
Signing Up for GitHub and Starting a Project
When starting a new project on GitHub, you must first create an account here using your email address.
Then, on verification of the address, the user will be automatically logged-into their GitHub account.
1. Creating a Repository
After this, one is taken to the next page that allows for the creation of a repository. A repository is a storage for all project files including revision history. Repositories are either, public or private. Public repositories are visible to everyone, however, the owner chooses an individual who can commit to the project. On the other hand, private repositories provide extra control to who can view the repositories. As a result, public repositories are suitable for open source software projects while private repositories are mostly suited to private or closed source projects.
- After filling the “Repository Name” and filling the “Short Description”
- Check the “Initialize this repository with a README”.
- Finally, click the “Create Repository” button at the bottom.
2. Adding a Branch
In GitHub, branches are a way of working on various versions of a single repository simultaneously. By default, any single repository created is assigned a branch called MASTER and it is considered the final branch. In GitHub, branches are useful in experimenting and editing of repositories before committing them to the master (Final branch).
For personal suitability, it is always necessary to add several other branches to suit different projects. Creating a branch off the master branch is the same as copying the master as it was at that instant.
Creating branches is similar to saving a single file in different versions. This is achieved by renaming according to the task being carried out on a particular repository.
Branches also prove useful in keeping bug fixes and feature work separated from the master branch. After necessary changes, these branches are merged into the master branch.
To make a branch after creating the repository;
- Go to your new repository by clicking on the repository name in this case, “Hello-World”.
- Click on the “Branch-Master” button at the top to see a drop-down menu with a blank field for filling the branch name.
- Enter the branch name, in this case, ”readme-edits”.
- Press “Enter” or click on the blue “create- branch” box
By now two branches have been created; master and readme-edits.
3. Making and Committing Changes
This step provides guidelines on how changes are made to a repository and saved. In GitHub, commits is the word used to refer to saved changes. Each commit is also associated with a commit message that contains a history of the saved changes and why particular changes were made. This makes it easy for other contributors to follow what was done and why.
To make and commit changes to a repository, the following are the steps;
- Click on the repository name “Hello-World”.
- To view and edit the file, click on the pencil icon in the upper right corner.
- In the editor, write something to ascertain that you can make changes.
- Write briefly in the commit message field to explain why and how the changes were made.
- Click on commit changes button to save the changes.
Please note that these changes only affect the readme-edits branch and not the master branch.
4. Opening a Pull Request
Pull request is a feature that allows a contributor to propose and request someone to review and merge certain changes to their branch. Pull requests also show the difference (diffs) from several branches. Changes, additions, and subtractions are usually shown in red and green colors. Pull requests can be started as soon as a commit is made. Even when the code is not finished.
To open a pull request:
- Click the pull request tab.
- Select the readme-edits branch to compare with the master.
- Determine the requirements and be sure it is what you want to submit.
- Click on the create pull request green button and assign it a title.
- Press enter.
The user can demonstrate this by trying to create and saving a pull request.
5. Merging the Pull Request
This final step involves bringing readme-edits and master branches together. The merge Pull button shows up in case the readme-edits and the master branch do not conflict.
When merging pulls, there is need to ensure that the comments and other fields are filled properly. To merge pulls:
- Click on the merge pull request button.
- Confirm the merge.
- Press the purple delete branch button to delete the readme-edits branch since it is already incorporated in the master.
This article provides a simple guideline to getting started with GitHub and other basic operations of the GitHub platform.
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.