Skip to main content

Using Git Without Github's GUI

My current project is at a company that hosts its own git repository. I use the command line for my own work, so it was a surprise how much I rely on Github's web UI for code reviews and managing branches.

Here are some commands and tricks I didn't know about until the GUI was gone.

The client code isn't hosted on Github, so I have a separate set of SSH credentials. This article describes how to manage multiple SSH keys.

We use feature branches. I prefer to work small and merge often, so they pile up. It gets messy fast.

What are all the branch names?

  • git branch lists local branches.
  • git branch -r lists remote branches.
  • git branch -a shows all branches, local and remote.

Use git branch --merged to show which branches have been merged. git branch --no-merged shows branches which are still unmerged.

We prefer to remove branches once they're merged. Pushing the branch to the remote with a colon before the branch name - git push origin :your_branchname_here - deletes it on the remote. git branch -D your_branchname_here deletes it locally.

For code reviews, git log lists commits. git show prints the diff from the last commit.

Finally, sometimes a picture saves a thousand words. Git clients like Source Tree or Tower offer a nice visual map of the state of a repository, especially one with several prolific contributors.