GitHub Desktop

What you are looking at

GitHub Desktop is a free app from GitHub that runs Git for you. The window has three parts. The top bar shows the repository, the branch, and one button that talks to GitHub: Fetch, Push or Pull, whichever is needed now. The left pane lists the files you changed, with a summary box and a commit button under it. The right pane shows the changed lines of the file you select.

Everything the app does is a Git command. Knowing which one helps when something goes wrong, and when you move to the terminal later. The pages on Git and GitHub explain the commands themselves.

Set up

  1. Download it from desktop.github.com and install it. It brings Git with it.
  2. File › Options (Preferences on a Mac) › Accounts: sign in to GitHub.com. This is how pushes are allowed.
  3. In the same place, Git: check that your name and email are set. They go into every commit.

Get a repository

File › Clone repository shows every repository your account can reach. Pick one, choose a folder on your computer, press Clone. To start from a folder of your own instead, File › Add local repository, or File › New repository, and then Publish repository in the top bar to put it on GitHub.

Commit

Edit files in any editor. Each changed file appears under Changes with a tick. Untick a file to leave it out of the commit. Select a file to see its changed lines on the right. Type a summary, then press Commit to main. The commit is on your computer only, and the top button changes to Push origin.

In the windowThe command
The Changes listgit status
The changed lines on the rightgit diff
Commit to maingit add and git commit
Push origingit push
Fetch origingit fetch
Pull origingit pull
History tabgit log

Push, fetch and pull

Push origin sends your commits to GitHub. Fetch origin asks GitHub whether anyone else pushed; if they did, the button becomes Pull origin, and pressing it brings their commits down. Desktop fetches on its own every few minutes, so the button is usually right already.

If a push is refused because someone pushed before you, Desktop offers to fetch and merge. If you both changed the same lines, it lists the files with conflicts, you open each one in your editor, keep the lines you want, and commit. The same as on the command line, with the steps laid out.

Branches and pull requests

Current branch › New branch makes a branch and switches to it. Commit on it, press Publish branch, and Desktop shows a Create Pull Request button that opens the pull request page on GitHub. After the pull request is merged there, switch back to main and press Pull origin.

When the window is not enough

Repository › Open in Terminal opens a command line in the project folder. Anything you do there shows up in the window right away. Desktop and the terminal are two views of the same repository, not two systems.

Check your understanding

  1. You press Commit to main. Can a teammate see the commit?
  2. The top button says Pull origin. What happened, and what will pressing it do?
  3. You changed three files but want to commit two. What do you do in the Changes list?
  4. Which Git command does Fetch origin run, and what does it not do?

Summary

Takeaways