Set up GitHub Desktop

  1. I'd Rather Be Writing
  2. Learn API Doc
  3. Publishing your API documentation

Activity: Use the GitHub Desktop client

Last updated: Dec 25, 2018

Although most developers use the command line when working with version control systems, there are many GUI clients available that can potentially simplify the process. GUI clients might be especially helpful when youre trying to see what has changed in a file since the GUI can quickly highlight and indicate the changes taking place.

  • Follow a typical workflow with a GitHub project using GitHub Desktop
  • Create a branch
  • Merge the development branch into master
  • Merge the branch through a pull request
  • Managing merge conflicts
  • Conclusion

Follow a typical workflow with a GitHub project using GitHub Desktop

In this tutorial, youll use GitHub Desktop to manage the Git workflow.

Rather than working in a GitHub wiki (as you did in the previous GitHub tutorial), youll work in a regular Git repository. This is because GitHub wikis have some limitations when it comes to making pull requests.

To set up your Git repo using the GitHub Desktop client:

  1. First, download and install GitHub Desktop. Launch the app and sign in. (You should already have a GitHub account from previous tutorials, but if not, create one.)
  2. Go to Github.com and browse to the repository you created in the GitHub tutorial, but not the wiki. Just go to the main repo. (If you didnt do the previous activity, just create a new repository.)
  3. While viewing your GitHub repo in the browser, click Clone or download and select Open in Desktop.

    Set up GitHub Desktop
    Open in GitHub Desktop
  4. Open GitHub Desktop client and go to File > Clone Repository.
  5. In the confirmation dialog, select Open GitHub Desktop.app. GitHub Desktop should launch with a Clone a Repository dialog box about where to clone the repository. If desired, you can change the Local Path.
  6. Click the URL tab, and then paste in the clone URL. In the Local Path field, select where you want the repo cloned. For example:

    Set up GitHub Desktop
    Selecting paths for the repo in GitHub Desktop
  7. Click Clone.
  8. Go into the repository where GitHub Desktop cloned the repo (use your Finder or browse the folders with Finder or Explorer) and either add a simple text file with some content or make a change to an existing file.
  9. Go back to GitHub Desktop. Youll see the new file you added in the list of uncommitted changes on the left.

    Set up GitHub Desktop
    Uncommitted changes shown

    In the list of changed files, the green + means youve added a new file. A yellow circle means youve modified an existing file.

  10. In the lower-left corner of the GitHub Desktop client (where it says Summary and Description), type a commit message, and then click Commit to master.

    When you commit the changes, the left pane no longer shows the list of uncommitted changes. However, youve committed the changes only locally. You still have to push the commit to the remote (origin) repository. (origin is the alias name that refers to the remote repository.)

  11. Click Push origin at the top.

    Youll see GitHub Desktop show that its Pushing to origin.

    Set up GitHub Desktop

If you view your repository online, youll see that the change you made has been pushed to the master branch on origin. You can also click the History tab in the GitHub Desktop client (instead of the Changes tab), or go to View > Show History to see the changes you previously committed.

Although I prefer to use the terminal instead of the GitHub Desktop GUI, the GUI gives you an easier visual experience to see the changes made to a repository. You can use both the command line and Desktop client in combination, if you want.

Create a branch

Now lets create a branch, make some changes, and see how the changes are specific to that branch.

  1. In the GitHub Desktop client, go to Branch > New Branch and create a new branch. Call it development branch, and click Create Branch.

    Set up GitHub Desktop
    Creating a new branch

    When you create the branch, youll see the Current branch drop-down menu indicate that youre working in that branch. Creating a branch copies the existing content (from the branch youre currently in, master) into the new branch (development).

    Set up GitHub Desktop
    Working in a branch
  2. Using Finder or Explorer, browse to the file you created earlier and make a change to it, such as adding a new line with some text. Save the changes.
  3. Return to GitHub Desktop and notice that on the Changes tab, you have new modified files.

    Set up GitHub Desktop
    New files modified

    The file changes show deleted lines in red and new lines in green. The colors help you see what changed.

  4. Commit the changes using the options in the lower-left corner, and click Commit to development.

  5. Click Publish branch (on the top of the GitHub Desktop window) to make the local branch also available on origin (GitHub). (Remember, there are usually two versions of a branch the local version and the remote version.)

  6. Switch back to your master branch (using the Branch drop-down option at the top of the GitHub Desktop client). Then look at your file (in your text editor, such as Sublime text). Note how the file changes you made while editing in the development branch dont appear in your master branch.

You usually create a new branch when youre making extensive changes to your content. For example, suppose you want to revamp a section (Section X) in your docs. However, you might want to publish other updates before publishing the extensive changes in Section X. If you were working in the same branch, it would be difficult to selectively push updates on a few files outside of Section X without pushing updates youve made to files in Section X as well.

Through branching, you can confine your changes to a specific version that you dont push live until youre ready to merge the changes into your master branch.

Merge the development branch into master

Now lets merge the development branch into the master branch.

  1. In the GitHub Desktop client, switch to the branch you want to merge the development branch into. From the branch selector, select the master branch.
  2. Go to Branch > Merge into Current Branch.
  3. In the merge window, select the development branch, and then click Merge development into master.

    Set up GitHub Desktop
    Merging into master

    If you look at your changed file, you should see the changes in the master branch.

  4. Then click Push origin to push the changes to origin.

    You will now see the changes reflected on the file on GitHub.

Merge the branch through a pull request

Now lets merge the development branch into the master using a pull request workflow. Well pretend that weve cloned a repo managed by engineers, and we want to have the engineers merge in the development branch. (In other words, we might not have rights to merge branches into the master.) To do this, well create a pull request.

  1. Just as you did in the previous section, switch to the development branch, make some updates to the content in a file, and then save and commit the changes. After committing the changes, click Push origin to push your changes to the remote version of the development branch on GitHub.
  2. In the GitHub Desktop client, while you have development branch selected, go to Branch > Create Pull Request.

    GitHub opens in the browser with the Pull Request form opened.

    Set up GitHub Desktop
    Pull request

    The left-facing arrow (pointing from the development branch towards the master) indicates that the pull request (PR) wants to merge the development branch into the master branch.

  3. Describe the pull request, and then click Create pull request.

  4. At this point, engineers would get an email request asking for them to merge in the edits. Play the part of the engineer by going to the Pull requests tab (on GitHub) to examine and confirm the merge request. As long as the merge request doesnt pose any conflicts, youll see a Merge pull request button.

    Set up GitHub Desktop
    Confirm merge request
  5. To see what changes youre merging into master, you can click the Files changed tab (which appears on the secondary navigation bar near the top). Then click Merge pull request to merge in the branch, and click Confirm merge to complete the merge.

  6. Now lets get the updates you merged into the masterbranch online into your local copy. In your GitHub Desktop GUI client, select the master branch, and then click the Fetch origin button. Fetch gets the latest updates from origin but doesnt update your local working copy with the changes.

    After you click Fetch origin, the button changes to Pull Origin.

  7. Click Pull Origin to update your local working copy with the fetched updates.

    Now check your files and notice that the updates that were originally in the development branch now appear in master.

For a more detailed tutorial in making pull requests using the GitHub interface, see Pull request workflows through GitHub. I include an extensive tutorial with pull requests because it will likely be a common workflow if you are contributing to an open-source project.

Managing merge conflicts

Suppose you make a change on your local copy of a file in the repository, and someone else changes the same file using the online GitHub.com browser interface. The changes conflict with each other. What happens?

When you click Push origin from the GitHub Desktop client, youll see a message saying that the repository has been updated since you last pulled:

The repository has been updated since you last pulled. Try pulling before pushing.

The button that previously said Push origin now says Pull origin. Click Pull origin. You now get another error message that says,

We found some conflicts while trying to merge. Please resolve the conflicts and commit the changes.

If you decide to commit your changes, youll see a message that says:

Please resolve all conflicted files, commit, and then try syncing again.

The GitHub Desktop client displays an exclamation mark next to files with merge conflicts. Open up a conflict file and look for the conflict markers (<<<<<<< and >>>>>>>). For example, you might see this:

<<<<<<< HEAD This is an edit I made locally. ======= This is an edit I made from the browser. >>>>>>> c163ead57f6793678dd41b5efeef372d9bd81035

(From the command line, you can also run git status to see which files have conflicts.) The content in HEAD shows your local changes. The content below the ======= shows changes made by elsewhere.

Fix all the conflicts by adjusting the content between the content markers and then deleting the content markers. For example, update the content to this:

This is an edit I made locally.

Now you need to re-add the file to Git again. In the GitHub Desktop client, commit your changes to the updated files. Then click Push origin. The updates on your local get pushed to the remote without any more conflicts.

Conclusion

The more you use GitHub, the more familiar youll become with the workflows you need. Git is a robust, powerful collaboration platform, and there are many commands and workflows and features that you could adopt for a variety of scenarios. Despite Gits variety of commands and workflows, most likely the scenarios youll actually use are somewhat limited in scope and learnable without too much effort. Pretty soon, these workflows will become automatic.

Although weve been using the GitHub Desktop client for this exercise, you can do all of this through the command line, and youll probably find it preferable that way. However, the GitHub Desktop client can be a good starting point as you transition into becoming more of a Git power user.

Set up GitHub Desktop
Buy me a coffee
Stay updated
Keep current with the latest trends in technical communication by subscribing to the I'd Rather Be Writing newsletter. 5,500+ subscribers. (See email archive here.)

103% Complete

103/162 pages complete. Only 59 more pages to go.


« Previous: Activity: Manage content in a GitHub wiki
NEXT » Pull request workflows through GitHub