8. $ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
$ git config --global user.email "your_email@youremail.com"
# Sets the default email for git to use when you commit
$ git credential-osxkeychain
# Test for the cred helper
Usage: git credential-osxkeychain <get|store|erase>
8
9. $ git credential-osxkeychain
# Test for the cred helper
git: 'credential-osxkeychain' is not a git command. See 'git
--help'.
$ curl -s -O http://github-media-downloads.s3.amazonaws.com/
osx/git-credential-osxkeychain
# Download the helper
$ chmod u+x git-credential-osxkeychain
# Fix the permissions on the file so it can be run
$ sudo mv git-credential-osxkeychain /usr/local/git/bin
# Move the file so git can access it
# Password: [enter your password]
9
10. $ git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
10
13. $ cd ~/.ssh
$ ls
config id_rsa id_rsa.pub known_hosts
$ mkdir key_backup
$ cp id_rsa* key_backup
$ rm id_rsa*
$ ssh-keygen -t rsa -C "your_email@youremail.com"
# Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa):
[Press enter]
Enter passphrase (empty for no passphrase): [Type a
passphrase]
Enter same passphrase again: [Type passphrase again]
Your identification has been saved in /Users/you/.ssh/id_rsa.
Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db
your_email@youremail.com
13
14. $ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
14
15. $ ssh -T git@github.com
# Attempts to ssh to github
The authenticity of host 'github.com (207.97.227.239)' can't
be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:
56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
Hi username! You've successfully authenticated, but GitHub
does not provide shell access.
15
19. $ mkdir ~/Hello-World
# Creates a directory for your project called "Hello-World"
in your user directory
$ cd ~/Hello-World
# Changes the current working directory to your newly
created directory
$ git init
# Sets up the necessary Git files
Initialized empty Git repository in /Users/you/Hello-
World/.git/
$ touch README
# Creates a file called "README" in your Hello-World
directory
19
20. $ git add README
# Stages your README file, adding it to the list of files to
be committed
$ git commit -m 'first commit'
# Commits your files, adding the message "first commit"
$ git remote add origin https://github.com/username/Hello-
World.git
# Creates a remote named "origin" pointing at your GitHub
repo
$ git push origin master
# Sends your commits in the "master" branch to GitHub
20
21. Fork A Repo
$ git clone git@github.com:oboegrace/git-101.git
https://help.github.com/articles/fork-a-repo
21
26. TheThree States of Git
• Committed
• Data is safely stored in your local database.
• Modified
• You have changed the file but have not committed it to your
database yet.
• Staged
• You have marked a modified file in its current version to go
into your next commit snapshot.
26
27. The basic workflow of Git
1. You modify files in your
working directory.
2. You stage the files,
adding snapshots of
them to your staging
area.
3. You do a commit, which
takes the files as they
are in the staging area
and stores that snapshot
permanently to your Git
directory.
27