This is a quick-and-dirty guide for working with Git from the MacOSX Terminal.

FAQ

Why is this needed?

Working with Github is great for version control and collaborating on projects.

Yet, many of my project partners have expressed fear about working with Github and especially working with the Terminal.

Fortunately, you only need to know a few basic steps to use Git smoothly and effectively.

Who is this for?

This is for new users to Github.

The users should have some familiarity to coding, but this is not exactly needed.

These steps are meant for co-equal collaborators. They will work with Forks, but the beginning part is a little different.

Disclaimer: These guidelines are for Mac OSX users, but I believe are easily transferrable to Windows.

External resources

  1. Pro Git book
  2. PDF Cheatsheet
  3. Hubspot

Using Git from Terminal

Clone directory

  1. Copy clone https link from Github
    e.g. https://github.com/niklaslollo/niklaslollo.github.io.git

  2. Navigate to chosen location using terminal cd <folder>/<folder>/

  3. Clone it:
    git clone <link>

Check status

You will want to check status early and often. Do this between each step as you get used to working with git.

The terminal will return a response detailing what is happening and provide suggestions for what you might want to do.

git status

Branches

You will want to work on a branch of the master, then merge it later.
git checkout -b <branchname>

To navigate around branches:
git checkout <branchname>

Add files or updates

You will want to send your updates to the branch on which you were working. Use the status check to figure out which branch you are on.

  1. Add files or updates
    git add . adds every possible update in your repo. Recommended
    git add <file> adds only that file or its updates.

  2. Commit and add a message
    git commit -m "message"
    Try to be succinct, but descriptive in your message. This tags the update for future reference.

  3. Push to github
    git push

Merging with master branch

  1. Create pull request from your branch on Github.

  2. Another partner reviews and decides whether to merge or ask for edits.

  3. Assuming it passes the review, that partner accepts and merges the branch with Master. Then the branch should be deleted on Github.

  4. Delete local branch using Terminal.
    git branch -d <branch_name>