GitHub Desktop Tutorial – Collaborate With GitHub From Your Desktop

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated March 7, 2024

This Tutorial Explains how to Download and use the GitHub Desktop to Collaborate With GitHub From Your Desktop for Efficient Version Control:

As we all know, GitHub provides a website to host Git repositories. In our previous tutorials on GitHub, we have seen the developer’s activities on versioning files mostly on GitHub.

There is also a Git Client wherein the developers can work on the repository offline on their local machines using git commands from the command prompt or git bash, make changes and push it back to the remote repository on GitHub.

=> Visit Here To Learn GitHub From Scratch

Working with GitHub Desktop

GitHub Desktop

Though the Git commands executed from the command line are great from a learning point of view, there is a good user interface to work on the local repositories i.e. GitHub Desktop.

GitHub Desktop for Windows can be downloaded and installed from the following URL

Launch GitHub Desktop

Launch GitHub Desktop

Work With The Remote Repository

Once the GitHub desktop is launched, we can start by cloning the remote repository to the local machine, make changes and push it back to the remote repository.

Account Settings

In GitHub Desktop, go to File => Options and ensure your GitHub account is setup.

Account settings

In GitHub Desktop, to clone a repository select File => Clone Repository

Clone Repository

Go to the URL tab and enter the remote repository details in the form of the GitHub Username/repository. Click on Clone.

Clone a Repository

Now as the repository is cloned to the local machine, we can open the local repository contents using command prompt or explorer or even Atom editor if installed and make changes to the files.

Open In command prompt

Make changes to the files and save the same.

Make changes to the files and save

Back in the GitHub Desktop, you can see the RED marking which specifies if the lines were added or were deleted.

RED markings

Add a Summary and Co-authors if needed and click on Commit to master at the bottom.

You will notice that most of the git commands that you execute from the command prompt have been done through the user interface.

We can now push the changes to the remote repository in GitHub. Click on Push origin.

Push origin

Now the changes are visible in the master branch. To ensure that the changes are merged to the feature branch we will need to create a Pull Request.

Further Reading => GitHub Advanced Security – An Introductory Tutorial

Switch to the feature branch and create a Pull Request.

Switch to the feature branch

Click on Create Pull Request.

Create Pull Request

You are then re-directed to GitHub to create the Pull Request.

Open Pull request

Proceed to create and merge the Pull Request and then finally pull(sync) the changes to your local repository.

Merging Pull Request

From the Repository, the menu selects the Pull option.

Select the Pull option

Now the local repository would be in sync with the remote repository.

Create A New Local Repository And Branch

In the previous section, we learned about working with the remote repository by cloning it. Using GitHub desktop, we can also create a new local repository and push or publish the same to GitHub.

Click on File =>New Repository

New repository

Enter the name of the repository and the local path. Click on Create Repository.

Enter the name of the repository and the local path

As the repository is created, you can also create a branch before you publish/push the changes to GitHub.

Select New branch from the Branch menu. Call it to feature and click on Create branch.

Create branch

Now we do have 2 branches and we can proceed to Publish / Push the changes to GitHub. Click on Publish repository.

Publish repository

Click on Publish Repository.

Enter Name

As there is also a Feature branch, you must publish the feature branch as well. Now the changes can be made to the files locally and then push the changes to the remote repository. Changes in the remote repository should also be in sync with the local repository.

Merge Changes In Local Repository

Assume that there are changes in the feature branch in the local repository. We can merge the changes to the master branch. Post this we should push the changes of the master and feature branch to GitHub.

Make a change to a file in the feature branch and commit the same.

Commit to feature

Push the changes to the remote repository.

Push changes to remote repository.

Switch to the Master branch and click on Branch =>Merge into the current branch.

Merge into current branch

Select the Feature branch which is the source branch. Click on the Merge button.

Merge feature into master

Once the changes are merged into the master branch, you can then push the changes to the remote repository to be in sync.

All the changes committed to branches in the local repository can be merged and pushed to the remote repository to be in sync.

Push 2 Commits to the origin remote

Resolving Conflicts

There could also be a scenario where the changes have been committed to a file in the remote repository and also a change to the same file locally. In this case, the conflicts would be seen and would need to be resolved to have both the remote and local repository to be in sync.

Further Reading => A Complete Guide on GitHub Packages

Remote repository changes committed in the Master branch

Remote repository changes committed in master branch

Local repository changes committed in the master branch

Local repository changes committed in master branch

As the changes are committed to the local repository, you can now push the changes to the remote repository. The conflicts will be seen while doing this. Click on Push origin.

Push 1 commit to the Origin Remote

The following message would appear as there are changes in the remote repository to the same file. Click on Fetch.

Click on Fetch

Now click on Pull origin.

Pull Origin

In the screen that comes up, you can open the file in your editor and resolve the conflicts. In this case, we are opening the file in explorer and resolving the conflicts.

Resolve conflicts

README.md

Fix all of the conflicts by retaining the appropriate content and removing the others with markers. Once the conflicts are resolved, you can commit the merge.

Commit Merge

Now push the changes back to the remote repository. The local and remote repository is now in sync. As the changes have been done on one branch you can then create a Pull Request to merge the changes to the other branches.

Push2 Commits to the origin remote

Looking At History

You can also look at the history of changes done so far to the repository. Toggle to the History tab.

History Tab

Comparing Branches

Suppose you have done changes to a file in the master branch, you can then compare it with any of the other branches. Select Branch => Compare to branch.

Comparing Branches

Select the feature branch to look at the changes.

Select Feature Branch

Conclusion

Though the use of Git commands from the command line is great, we saw in this GitHub Desktop tutorial, how a great Git Client like GitHub Desktop with a good user interface can ease the developer’s work while working with the local and remote repositories.

In the upcoming tutorial, we will look at another Git client interface Tortoise Git that integrates with the Windows Explorer Shell.

=> Watch Out The Simple GitHub Training Series Here.

Was this helpful?

Thanks for your feedback!

Leave a Comment