Setup Your Local Repo Using Github Desktop With These Easy Steps

In this blog, we will know a simple way to setup our local machine using Github Desktop.

Let’s start with Github itself. Most of my friends that are not familiar with github or git commands, will always tell me that’s it’s hard for them to use it. Or shall I say it’s hard to remember the commands correspondence to git. From the old days, we usually use terminal or command line to pull and push to your repository. So it’s understandable especially if you haven’t tried git or github firsthand.

Github Desktop Intro

First thing we need, is to download the Github Desktop application to your computer. Second thing you need is to register in Github to clone or create a repository.

After downloading and registering, we can now start cloning a repository. It’s similar to copy and paste of files we usually do. Only this time its from a remote repository to your local working machine. Therefore, everything that we will do on our local copy of these files will not reflect on the remote or Github repository unless you will commit or push it.

Cloning a repository

From Github Desktop, select File > Clone repository

Let’s go back to github website to copy the clone link. Just like below:

After we have copied the HTTPS link, let’s switch back with Github Desktop.

Please don’t mind the input’s in the back and just focus with the highlighted boxes and numbers. 🙂

  1. The Github link that we copied earlier in the repo that’s under the HTTPS tab.
  2. Path where you want to change download the copied repo on your local.
  3. Similar to folder Choose options where you can select or change the path
  4. Finally, clone it and we should see the same result as below.

Github Desktop Elements Description

#1 Current Repository

Means in what repository you are in. You can have multiple repository that link to your github repo or other repos. For instance, in my local I have 3 repositories that I’ve clone(copied) from a repository.

#2 Current branch

As the name indicates, it will be the branches of your repo. If we will compare it to the real life situation, we can compare to the branches of a tree. Each branch of a tree differs on how many are in there. How many flowers or leaves that are withered, fully or early bloom.

To make the story short, it means that we can have different set of code on different branches. The branches in git are too complex to explain, so we wont go that far. We will be only talking about 2 branches.

  • main
    • Stable code or deployment for production code.
    • Only Manager/Leader should touch this.
  • develop
    • all the development (feature and fixes)
    • Every member should pull request if they want to merge their codes into this. There should be someone monitoring these pull request.

#3 Fetch Origin

Fetch or Pull means is to get all new from your remote repository then download and merge everything on your local project. As shown in the screenshot below, it indicate when was the last time your local project got updated.

#4 Changes

Indicates the local changes or the updates we did in the local project.

  • #1 Change file – what file that we’ve changed.
  • #2 Detail change file – on what certain part of that file that we’ve changed.
    • (-) means that original. The one that we clone in the repository.
    • (+) means what we change. You can see the highlighted part too.

#5 History

This is from the repo that we cloned. Displays all the push or commits that’s been made into the repository.

It should be noted that for these two tabs, the Changes tab is for your local while History is to your repository.

#6 Changes in Files

We will see two set of files that’s being displayed.

Changes Tab – files should be seen in here.

History Tab – commits should be seen in here.

#7 Commit Summary

This is a required field everytime we will push to github. Push means that we will upload our changes unto the repo for it to be updated with our changes. If it’s your first time committing to the repository, it might need to have a inputs before the Commit to <certain branch> button to be enabled. Apart from that, it will automatically get the last input we have writtenin the summary

As seen in below screenshot, we can see what was the last commit and it can be overwritten when we input something. In addition, the Commit to <certain branch> button is also active.

#8 Commit to <certain branch>

This is the most important step of all. We can’t update a certain repo in Github with our changes if we can’t click this button. There are two way’s in updating your repo.

Push to Github – Single Developer

If you are the only developer and mainainer of the repo, we can use main. It’s not advisable for a real project. However, as beginner we all start with creating one branch.

Push to Github – Multiple Developer

If there’s multiple person commiting in the same repository. The flow will be a bit different. We need to be careful in order not to have any conflict in your local or remote repo. These conflicts will cause headaches if it will not be fix.

Will start with updating your local repo/project to the latest repo in Github. We wont know if your teammates did update anything and it’s very inconvenient to ask them everytime. The fastest way to know if there’s an update should be fetching.

First if we have changes in the local project, then we will be stashing them. In real world, it have the same meaning – hide away. When we have a new update to our local but we don’t want it to be overriden or lose them by the updates in the repo in the Github when we fetch, then we stash them or keep them in temporary place and show it again later. To stash your changes, right click on the changed tab and click the Stash all changes.

Once successfuly stashed, we should see below info:

Now we will update our local project to the Github repo. Click the Fetch origin

Then we will unstash the changes or the one that you stash before. First, click the Stashed changes and the click Restore just like the screenshot below.

It should go back to the Changes tab and displays the files that you’ve changed.

Then we can commit our changes to Github repo. First, input in the summary, description and after that, click the commit button. Also, make sure that you are in the right branch. It should be #2 in this blog. Since I am the developer and maintainer of this repo, so I will commit to the main branch.

After successfully commit, your Changes tab > Changes files should be 0

Same with the first one above, we click the push origin. If we look closely, we can see how if we already push oru commits or not. We will see in here an arrow pointing upward, which means we still have pending commits.Click the push origin and it will be uploading your changes to the Githubg repository.

After successfull push to repo, it should be display in History. As per discussion in the earlier part, History shows what’s been push or commit to the remote repository. It show who and what are commit for.