Skip to content

Latest commit

 

History

History
153 lines (105 loc) · 4.47 KB

File metadata and controls

153 lines (105 loc) · 4.47 KB

GitHub Basics

Here's an online resource for Git that includes a downloadable e-book: http://git-scm.com/doc

Installing Git and GitHub

Get your account

All of Ratio's projects are stored on GitHub. Signing up for an account is free, and requires only your email address. Once you have an account you'll need to contact your practice lead to get added to the Ratio GitHub profile before you can start cloning and commiting to Ratio projects.

If you already have a GitHub account, use that! The profiles will be kept separate, and you'll only have to maintain one login. Sweet!

Configure your SSH keys

GitHub is a secure host, which means you'll need to be authenticated to use your account from your development machine. Configuring and registering your SSH keys with GitHub is outside the scope of this doc, but fortunately GitHub has a great reference for Windows, Mac and Linux users:

Download the desktop client

The easiest way to get up and running is to download one of the desktop clients. Not only will this give you a friendly GUI to get started with, it will also install the command-line tools you need to run Git in PowerShell or Terminal.

Further Reading

Git is a pretty intuitive version control system, but just like any other technology getting comfortable with it requires a bit of experimentation and research. These references will help to answer questions you might have after reading these docs.

Terminology

Repository

Git is a distributed version control system, which means that every project clone is its own fully-qualified repository. Usually the repository on GitHub under the RatioInteractive account is the main repository, and should be kept pristine.

Remotes

Any repository can be connected to any other repository as a remote. The repository you're working from is referred to as the local repository, and by convention the repository it was cloned from is called origin. Repositories can have any number of remotes, but to follow this doc you won't need more than origin.

Stage

While your editing a file, the changes you make will no longer be tracked by Git. Before you can make those changes permanent, you'll need to tell Git that you want to commit them by adding them to the stage.

Commit

Once all of your changes have been staged then you're ready to make them a permanent part of your file history by committing them.

Push

Changes committed to your local repository will only appear in your local repository's file history. You'll need to push them to the origin repository before they are persisted on the server.

Pull

To keep your local repository in sync you'll have to pull changes down from the origin repository from time to time.

Log

The log is a running history of commits. Every repository keeps its own log, and two repositories are considered "in sync" when their logs are equivalent.

Hash (SHA-1)

Each entry in the commit log has it's own unique hash key. If you ever need to reference or roll back to a previous commit, you'll identify it by this key. Oftentimes you won't have to refer to the entire key; the first 7 or so characters are enough to identify the commit:

# These all refer to the same commit
$ git show 1c002dd4b536e7479fe34593e72e6c6c1819e53b
$ git show 1c002dd4b536e7479f
$ git show 1c002d

Command-line Basics

Cloning a repository

$ cd /path/to/your/projects/dir
$ git clone https://github.com/RatioInteractive/CoolProjectBro.git
$ cd ./CoolProjectBro

Keeping your repository in sync

$ git pull origin master

Staging files for commit

$ git add /an/entire/directory
$ git rm -r /an/unwanted/directory
$ git status

Committing files locally

$ git commit -m 'Fix all the things!'

Reviewing your commit history

$ git log
$ get log --pretty=oneline

Pushing your files to the remote repository

$ git push origin master

Merging and Resolving Conflicts

Branching