What is git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

In English:

  • A great collaboration tool
  • A system that does not rely upon a central storage location for a project. Every person's copy of the project is a full copy.
source: git site

Why Git?

Because it is the best tool, not because it is perfect or easy.

(it won)

How PCS classes use Git

We teach you a few commands, just enough to get started. We teach you simple workflows that will teach you to effectively use git. Git has tons of commands. Don't try to learn them all. Learn them as you need them. We will show you which ones to get started with.

How PCS classes use Git

We do not recommend, nor do we teach you how to use graphical interfaces/ apps for git. They are handy for some people, especially those who already understand git. But please do not use one during this class. Use the command line only.

Vocabulary

Repo/ Repository: a place to put your stuff where git can keep track of it.

Installation

...if you haven't already

git install page

...and if you don't have Mac OS 10.9 or 10.10 .... this might get complicated

Basic Configuration for Class Workflows: Your Name

git config --global user.name "your name"

Basic Configuration for Class Workflows: Your Email

git config --global user.email email@provider.com

Basic Configuration for Class Workflows: Check Your Configuration

git config --global -l

Basic Configuration for Class Workflows: Push from Local Branch to Same-Named

git config --global push.default current

Basic Configuration for Class Workflows: A Friendly Configuration Setting For Development... no time to explain... just do it! ;-)

git config --global merge.defaulttoupstream true
SSH Setup Instructions, courtesy of github (click here)

*For greatest convenience, do not create a passphrase with your ssh key. It is an extra and arguably unnecessary layer of security.

Class Workflow

This repo is designed for you to be able to turn in your assignments. It will also set you up to be able to collaborate with classmates and future coworkers.

Class Workflow

clone the repo from github (in your case, a homework assignment or activity repo)

Class Workflow

Change directories to the directory you want to put your work in.

cd dev

Optionally, make a pcs or dev directory into which you will put all of your assignment repos.

mkdir pcs

don't forget to change directories into that directory

cd pcs

Class Workflow

Clone the repository from github (the one in which you clicked the little button)

git clone git@github.com:portlandcodeschool/jse-fall15-1.git

Class Workflow

Change directories into the repo you just cloned:

cd some-directory

If you are not sure which directory you are in, type:

pwd

To see what is in your current directory, type:

ls

Class Workflow

Before you do anything else: make a new repo branch with your name!

git checkout -b yourNameHere

This keeps any changes you make out of the master branch until it's time to merge them.

Class Workflow

In addition, so we're protected by both belt and suspenders, put all of your changes in a subdirectory with your name:

mkdir yourNameHere

Then move to that directory:

cd yourNameHere

Additional Workflow Safety:

Don't modify the original assignment files or README.md

If you need to modify them, copy them somewhere else first.

Class Workflow

Now you can safely create and edit files. You can create files with the touch command, like this:

touch file-1.js

touch index.html

touch instructions.md

Class Workflow

You can check the status of your git repository like this:

git status

Class Workflow

You can add files for git to track like this:

git add name-of-file.js

Class Workflow

You will need to make commits so that git will "save" your code

git commit -m "make changes to all the things"

Don't forget the -m .... you'll be sorry ;-)

Class Workflow

Next, we need to get our code "saved" to github, our remote repository:

git push

Class Workflow

Head back over to github