< Back

Git Tutorial - Longboi Locator

Harry Wickham on November 07, 2022

This is a tutorial on how to use Git and GitHub. In this tutorial, we'll be using the Longboi Locator project as an example. A GitHub account is required to complete this tutorial.

Git Tutorial: Longboi Locator

What is Git?

Git is a version control system. It allows you to keep track of changes to your code. It also allows you to collaborate with other developers on the same project.

What is GitHub?

GitHub is a website that allows you to store your code online. It uses Git to keep track of changes to your code.

Getting added to the GitHub team

To get added to the GitHub team, you'll need to send us your GitHub username/email address. Please send this in an email to yordevs@yusu.org. Once we have received your email, we'll add you to the team.

Finding the Longboi Locator project

Once you have been added to the team, you should be able to find the Longboi Locator Team here. You can find the project and repository connected to the team.

The project is a way of keeping track of all of the development that is: to do, in progress, and completed. The repository is where the code is stored.

Cloning the repository

If you have your own computer and have git installed and connected to your GitHub account, you can clone the repository to your computer. Create a folder on your computer where you want to store the project. Then, open a terminal and navigate to that folder. Then, run the following command:

git clone https://github.com/yordevs/longboi-locator.git

This will create a new folder called longboi-locator in the folder you are in. This folder will contain all of the code for the project.

Creating a new branch

When you are working on a project, you should always create a new branch for each feature you are working on. This is so that you don't accidentally break the code that is already working. To create a new branch, run the following command:

git checkout -b <branch-name>

Replace <branch-name> with the name of the branch you want to create. For example, if you are working on a feature called "add-user", you would create a branch called add-user.

Making changes to the code

Once you have created a new branch, you can make changes to the code. Make any changes you want, this is just to test that everything is working correctly.

Logging into git on a Uni computer

If you are using a uni computer and are using VSCode as your editor, you can log into your github account using the following commands:

git config --global user.email <you@example.com>
git config --global user.name <Your Name>

Replace the email and username with those that are associated with your GitHub account. Continue with the next step, you will then be asked to log in to your GitHub account. After logging in through your browser your commit and push should go through.

Committing your changes

Once you have made your changes, you need to commit them. This means that you are saving your changes to your local repository. To commit your changes, run the following command:

git add --all
git commit -m "<commit-message>"

git add --all adds all of the changes you have made to the commit. git commit -m "<commit-message>" commits your changes to your local repository. Replace <commit-message> with a message that describes the changes you have made. For example, if you have added a new user, you could use the message "Added new user".

Pushing your changes

Once you have committed your changes, you need to push them to the remote repository (GitHub). To do this, run the following command:

git push --set-upstream origin <branch-name>

This will create your new branch in github and push your changes to it.

Creating a pull request

Once you have pushed your changes to GitHub, you need to create a pull request. This is a request to merge your changes into the main branch. To do this, go to the GitHub repository and click on the "Pull requests" tab. Then, click on the "New pull request" button. Select the branch you want to merge into the main branch. Then, click on the "Create pull request" button. Add some further information about the code you have written to allow the reviewer to have a better idea of what they are looking at. Finally, click on the "Create pull request" button again.

This will create a pull request. The reviewer will then review your code and either approve it or request changes. Once the reviewer has approved your code, it will be merged into the main branch.

You can keep making changes to your code on your branch and every time you stage, commit and push your code it will be added to the pull request. Once the reviewer has approved your code, you can delete your branch and make a new one for the next feature you are work on.