GitHub is an online platform owned by Microsoft used for hosting code. It is used for version control and collaboration and lets developers work on a project at the same time from anywhere.
On GitHub, developers can easily create repositories that are usually used to organize projects. These repositories can contain folders, files, images, videos, spreadsheets, data sets, or anything your project needs. They also come with a Readme.md file, which is a place to describe your project and provide information about it.
How to Create a Repository
Follow these steps when creating a repository.
- Click on +, located in the upper right corner of the page. Then select New Repository.
- Choose a name for your repository (I will use “Hi Everyone”).
- Write a brief description of the repository.
- Select Initialize this repository with a README.
- Click on the Create repository button.
How to Create a Branch
When different developers want to work on the same document at the same time, they use a feature of GitHub called Branching. By default, when you create a repository, it only has one branch called the master branch. Branches are used to experiment or edit code before finally assigning them to the master branch.
When a branch is created off a master branch, the new office is a copy of the master branch at the time the department was created. Also, if after creating your branch, someone makes changes to the master branch, you can pull in those changes to your new branch.
Steps for creating a new branch
- Go to your new repository, “Hi, Everyone.”
- Click the drop-down at the top of the file list that says branch: master.
- Type a name for your new branch, say, ‘illusBranch,’ into the new branch text box.
- Click on the Create branch box or tap “Enter” on the keyboard.
Making and Committing Changes
You are now on the code view for your ‘illusBranch,’ which is a copy of the master branch. On the GitHub platform, any changes you make and save are known as ‘commits.’ They have an attached entry that details what those changes were.
Make and Commit Changes
- First, click on the Readme.md file.
- Next, click the pencil icon in the file view’s right corner. It will enable you to edit the code.
- When the editor opens, type in the changes you want to make.
- Write a commit message that best describes the changes you have made to the readme.md file.
- Click on the Commit Changes button.
How to Open a Pull Request
You have now made changes to a branch of the master and can pull a request. When you open a pull request, you are presenting your proposed changes and asking for a review from others. If the reviewers accept your changes, then they will merge your proposed changes into their branches. Pull requests show differences in the content from both branches. All changes will show up in either red or green colors. You can access a commit with a pull request immediately after creating it to open a discussion around it.
How to Mark Files as Viewed
For developers who work on large codebases, it is rare to avoid large pull requests. It can take several hours to search through and review files. The time spent on searching can make someone easily forget where he/she was. An easy way to keep track of the data you have reviewed is by marking files as viewed.
Steps for Marking a File as Viewed
You can see your progress at the top of the pull request. This is where you’ll see the files you have viewed and the ones you have yet to see. When you mark a file as viewed, it will automatically collapse, which makes it easier to review.
The images below help illustrate the steps.
- Create a Pull Request.
- Open the Pull request to see all newly added or edited files.
- Click on a file to mark it as viewed. This collapses the file.
Marking a file is a handy feature in GitHub to help reviewers focus on their work and easily keep track of their progress. The Viewed feature also lets you know when anything changes in the code you have already viewed.
For example, if you open a file and someone also reviews and changes anything in the code after you have already done so, the Viewed status will change to “Changed since last view.” This also allows you to check what others have altered during their reviews.
Wrapping Up
Coding a new project by yourself may seem daunting, so don’t go it alone! Microsoft has made collaboration easy and effective with GitHub.
Did this help? Let us know!