Git Workshop

42
git workshop

description

A workshop for installing git, initializing and comitting to a repository, and pushing the repository to github.com.

Transcript of Git Workshop

Page 1: Git Workshop

git workshop

Page 2: Git Workshop

ABOUT ME

Alex YorkConsultant

www.alexyork.net@alex_york

Page 3: Git Workshop

“You stupid git!”

Page 4: Git Workshop

msysgit

http://code.google.com/p/msysgit/

Git client for Windows

Page 5: Git Workshop

Installing msysgit (1)

Page 6: Git Workshop

Installing msysgit (2)

Page 7: Git Workshop

Installing msysgit (3)

Page 8: Git Workshop

Installing msysgit (4)

Page 9: Git Workshop

Open “Git Bash”

Page 10: Git Workshop

Names with Æ Ø Å

• Add an environment variable for HOME– So that git will not look in:– C:\Users\Follesø

• Right click on My Computer• Advanced System Settings• Environment Variables• Add

Page 11: Git Workshop

Names with Æ Ø Å

Page 12: Git Workshop

Names with Æ Ø Å

Page 13: Git Workshop

Names with Æ Ø Å

Page 14: Git Workshop

First git command: check version

git --version

Page 15: Git Workshop

Configure your email

git config --global user.email [email protected]

Page 16: Git Workshop

Configure your name

git config --global user.name “Alex York”

Page 17: Git Workshop

Generate SSH keys

ssh-keygen –C  “[email protected]”  –t rsa

That C is UPPERCAS

E!

Page 18: Git Workshop

Generating SSH keys

Press Enter/Return when prompted for file location and your passphrase.

Page 19: Git Workshop

Generated SSH keys

The public key will be used later on github.com.Pro tip: make backups of these keys!

Page 20: Git Workshop

Write some code!

Page 21: Git Workshop

Navigating with Git Bash

cd /c/Code/NNUG-Hello-World/

Page 22: Git Workshop

Initializing a repository

git init

Page 23: Git Workshop

What just happened?

Page 24: Git Workshop

View current status

git status

Page 25: Git Workshop

Creating a .gitignore file

touch .gitignore

Page 26: Git Workshop

View current status

git status

Page 27: Git Workshop

Add to staging area

git add .

Page 28: Git Workshop

Add to staging area

Page 29: Git Workshop

Next: commit

• After adding (and removing?) several times to the staging area...

• ... commit to the repository

• committing is like a snapshot of your code

Page 30: Git Workshop

Committing to repository

git commit –m “Commit message goes here”

Page 31: Git Workshop

Committing to repository

Page 32: Git Workshop

Commit log

git log

Page 33: Git Workshop

github.com

Page 34: Git Workshop

SSH Public Key

Page 35: Git Workshop

New Repository (1)

Page 36: Git Workshop

New Repository (2)

Page 37: Git Workshop

You’ve created a github repo!

Page 38: Git Workshop

Add your remote repository

git remote add origin [email protected]:alexyork/NNUG-Hello-World.git

All on one line!

Page 39: Git Workshop

Push to your remote repo

git push origin master

Page 40: Git Workshop

github.com

Page 41: Git Workshop

What next?

• Find something cool on github– git clone [email protected]/whatever

• Fork something– Add a feature, fix a bug– Create a pull request

• Start up an open-source project!

Page 42: Git Workshop

Based on this guide

• Git For Windows Developers by Jason Meridth

• http://www.lostechies.com/blogs/jason_meridth/archive/2009/06/01/git-for-windows-developers-git-series-part-1.aspx

• These slides available at: www.alexyork.net