GitHub is a web hosted collaboration and version control solution that is opened sourced. The main purpose of this tool is to allow for developer teams to collaborate on projects virtually.
Developers and bloggers, typically use this tool to collaborate on community projects and companies use it in the same manner for corporate tech initiatives.
To use this tool you do not need to write any code, all you will need, is a internet connection and a understanding of the concepts of pull request, branches, commits and repositories. With a understanding of these concepts you can create projects to be shared with the community. You can also work on other projects that have been shared by the GitHub community.
In the steps below we will walk through the 4 GitHub concepts referenced above. Before you can begin this process you will need to go to GitHub and setup a account.
A GitHub repositories is like a file system folder, it is container used to store and organize files that relate to single project/solution. A repository and hold any file types that are need for a project or solution to run. This include README, image, video, excel, txt or any other file that may be need.
Note: It is a best practice to include a README file in each repository that provide information such as a project description and any critical information needed to setup or execute the project.
- Select New repository
- Name the repository
- Add a short description of the repository contents
- Initialize this repository with a README
Select New repository
Name, add a short description and Initialize the README file
Type the new branch name.
Click Create and you are done. The new respoistory is ready for use.
A few things to note when creating a repository.
- You can add a License and this will determine how the code you upload should be used. In this case I used the MIT License are it is the least restrictive.
- Directories can be Public or Private and as the names imply the public directories can be seen by anyone on GitHub and the private directories are not access to the public.
Now that we have create a repository we can talk about Branching.
Branching allow you to work on different version of your repositories at the same time without changing the master copy. This is really helpful when you want to make changes to the code base without modifying your working code base.
When you create a repository the master branch is created and is known as the definitive code branch. A branch is a snapshot of the master repository and is used to make change which can then be committed to the master branch.
Create a branch
Now that we have created a new dev branch we have two copies of our repositories and we can make changes in the dev branch without affecting the master branch.
In the dev branch you will make code changes test them and once you verify the changes are complete you can commit the changes to the master branch. Once code is comment to the master branch all subsequent pulls from this branch will have the newly committed changes.
When you are working with GitHub commits is the equivalent of a file save operation in a word doc. It save the changes and allows for you a add a message to be stored with the associate commit. This is helpful to document why changes are being made to the code.
Note: It is a good practice to add a messages with changes this will be very helpful when it comes to debugging and rolling back code changes.
- In the dev code view select “Upload Files”
- Browse and select file for upload
- Add a message for the change being committed
- Select Commit Changes
You can now see the committed changed file in the code view. Now that we have created a repository, made a branch of that repository and made changes to the branch we can move on to Pull Request. A Pull Request is what unlocks the power of GitHub.
A pull request is when you make a request to have your code reviewed and merged in the main(master) branch of code. When you make a pull request you will see a comparison that will highlight the difference in the code compared to the master branch.
After you make a commit that commit is eligible to make a pull request.
Open a Pull Request
- Select Pull request tab
- Click “New Pull Request “
- Select the compare branch
- Click View pull Request
- Verify information and add a comment
- Click Merge pull request
- Confrim Merge
We have completed the setup and basic use of GitHub. This post was design to help you get started using GitHub. I hope you found this post informational.
Please leave comment and feed back below.