On Github catalyst-training / git-academy
Presented by Julia and Evan
Open a shell, and...
# Install Git sudo apt-get install git # Configure Git, stores these in ~/.gitconfig git config --global user.name "my full name" git config --global user.email "your_email@example.com" git config --global core.editor vim git config --global color.ui auto
# Create a new homework repository mkdir homework cd homework git init git status
Should show something like...
trainer@academy ~ $ mkdir homework trainer@academy ~ $ cd homework trainer@academy ~/homework $ git init Initialized empty Git repository in /home/trainer/homework/.git/ trainer@academy ~/homework $ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
touch lab1.txt touch lab2.txt git status
Should show something like...
trainer@academy ~/homework $ vim lab1.txt trainer@academy ~/homework $ vim lab2.txt trainer@academy ~/homework $ git status On branch master Initial commit Untracked files: (use "git add ..." to include in what will be committed) lab1.txt lab2.txt nothing added to commit but untracked files present (use "git add" to track)
git add . git status
Should show something like...
trainer@academy ~/homework $ git add . trainer@academy ~/homework $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached ..." to unstage) new file: lab1.txt new file: lab2.txt
git commit
Puts you into a text editor requesting a commit message
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # # Initial commit # # Changes to be committed: #»······new file: lab1.txt #»······new file: lab2.txt #
Type something meaningful, like "Finished lab 1 + lab 2"
When you're ready, save and quit with :wq
git log
Should show something like...
trainer@academy ~/homework $ git log commit 93b4e770e61aaf1b0b7b20cb2b69c4a99278a664 Author: Julia Larsen Date: Tue Jan 12 01:30:52 2016 +1300 Finished lab 1 + lab 2
Note, because this is small, it wont open in a pager
git status git show
should give...
trainer@academy ~/homework $ git status On branch master nothing to commit, working directory clean trainer@academy ~/homework $ git show commit 93b4e770e61aaf1b0b7b20cb2b69c4a99278a664 Author: Julia Larsen Date: Tue Jan 12 01:30:52 2016 +1300 Finished lab 1 + lab 2 diff --git a/lab1.txt b/lab1.txt new file mode 100644 index 0000000..b1a17ba --- /dev/null +++ b/lab1.txt @@ -0,0 +1 @@ +old stuff +old stuff +old stuff diff --git a/lab2.txt b/lab2.txt new file mode 100644 index 0000000..d6d6d41 --- /dev/null +++ b/lab2.txt @@ -0,0 +1 @@ +old stuff +old stuff +old stuff
git diff vim lab1.txt # Check what changed git status git diff
Should show something like...
trainer@academy ~/homework $ git diff trainer@academy ~/homework $ vim lab1.txt trainer@academy ~/homework $ git status On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: lab1.txt no changes added to commit (use "git add" and/or "git commit -a") trainer@academy ~/homework $ git diff diff --git a/lab1.txt b/lab1.txt index b1a17ba..f55c2ce 100644 --- a/lab1.txt +++ b/lab1.txt @@ -1 +1,2 @@ old stuff +new stuff old stuff -removed stuff old stuff
git status git checkout . git status
Should give something like...
trainer@academy ~/homework $ git status On branch master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: lab1.txt no changes added to commit (use "git add" and/or "git commit -a") trainer@academy ~/homework $ git checkout . trainer@academy ~/homework $ git status On branch master nothing to commit, working directory clean
Change things: create, save, reset
Check things: state, history, changes
git clone < url >
http(s)://...
(s)ftp://...
git://...
file://...
Many projects host their code on Github
... But... Why Octocat?
Git has a command called octomerge
The internet is made out of cats
Octopus + Cat = Octocat!!
Git
Github
Go setup a Github account!
The best way to interact with Github is using ssh
SSH uses public/private key pairs
Lets set that up quickly
# Generate SSH keys ssh-keygen -t rsa -C "your_email@example.com" # You should see them in ~/.ssh ls -l ~/.ssh cat ~/.ssh/id_rsa.pub
Take the text from ~/.ssh/id_rsa.pub and put it into Github
To make this website, we'll be setting up a new repo
Go here --> http://pages.github.com
# For multiple checkouts or shared work git pull # After commiting, push those changes to github git push
Change things: create, save, reset
Check things: state, history, changes
Share your changes
All the Academy projects are hosted in Git
Find the coding guidelines Clone the code, hack on it, commit your work Submit your work...Submit how?
These slides are on Github
If you have any feedback, please raise an Issue
Go forth and be awesome!
open source technologists