git training with devaamo

39
Devaamo ry Git training with Devaamo Otto Kekäläinen Uusi Tehdas / New Factory Tampere 29.11.2012 slides updated 1.12.

Upload: otto-kekaelaeinen

Post on 01-Nov-2014

1.402 views

Category:

Technology


2 download

DESCRIPTION

Git training with Tampere-based developer community Devaamo ry (devaamo.fi) at New Factory on Nov 28th 2012.

TRANSCRIPT

Page 1: Git training with Devaamo

Devaamo ry

Git training with Devaamo

Otto Kekäläinen Uusi Tehdas / New Factory

Tampere 29.11.2012

slides

updated 1.12.

Page 2: Git training with Devaamo

Outline1. The story of Git2. Basic commands3. Git internals4. Doing it with Github5. Advanced commands6. Git everywhere

Page 3: Git training with Devaamo

1. Story of Git

Page 4: Git training with Devaamo

Git / t/ɡɪ”A silly, incompetent, stupid, annoying or childish person.”

http://en.wiktionary.org/wiki/git

Page 5: Git training with Devaamo

"I'm an egotistical bastard, so I name all my projects after myself.

First Linux, now Git”

Linus Torvalds, PC World. 2012-07-14

Page 6: Git training with Devaamo

Linus needed a new source code revision manager for Linux, and none of the available open source options at

the time where good enough, so he wrote his own in April 2005.

Kernel 2.6.12 was the first release managed by Git and version 1.0 of Git was released in December 2005.

Page 7: Git training with Devaamo

Design goals of Git:● distributed revision management● protection against corruption,

both accidental and hostile● speed

Page 8: Git training with Devaamo

Popularity doubled from 2011 to 2012!

Page 9: Git training with Devaamo

...but adoption would be faster if it was not so difficult to use.

Originally Linus did not intend end users to use Git directly, instead he tried to delegate to somebody else the task of making the actual command line

interface. We are still waiting for it...

Luckily Git has been simplified and documentation has improved over time, but some Git commands

still refer to Git internals that are difficult to grasp.

E.g. git-push: Update remote refs along with associated objects.

Page 10: Git training with Devaamo

2. Basic commands

Page 11: Git training with Devaamo

First obstacle: same terms with different meanings

Page 12: Git training with Devaamo

git initgit add example.txtgit commit -nam “First commit”# fill example.txt with text from http://git-scm.com/git commit -nam “Second commit”

git loggit diff HEAD^

Page 13: Git training with Devaamo

git config --global user.name "John Doe"git config --global user.email [email protected]

Page 14: Git training with Devaamo

git clone git://github.com/Seravo/events-manager-translations.git

# edit filesgit commit -nam “Updated translation”git push

git pull# edit filesgit commit -nam “Implemented X”git push

git blame readme.txt

Page 15: Git training with Devaamo

3. Git internals

Page 16: Git training with Devaamo

Folder /.git contains everything,your / is just the working copy.

Page 17: Git training with Devaamo

Folder /.git contains everything,your / is just the working copy.

When you commit a 2 MB file /example.png,your / will grow to 4 MB...

Page 18: Git training with Devaamo

When you add a file,it goes to the staging area.

The file does not go into theactual history tree until the stage

is committed.

Page 19: Git training with Devaamo

Push and pull and many other commandsare short cuts that act with both

your local repository and the remote repositories.

Page 20: Git training with Devaamo

Image credits Steve Bennet (http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/)

Page 21: Git training with Devaamo
Page 22: Git training with Devaamo

Git tracks content, not files!

SHA-1 everywhere, if you need tochange something in the history,

you have to rebase and build a new history.

Page 23: Git training with Devaamo

4. Doing it with Github

Page 24: Git training with Devaamo

Visit http://try.github.com/

After making your first repository, set up SSH keyfor convenient authentication:

https://help.github.com/articles/generating-ssh-keys

Note: Github is not the only Git hosting site,Gitorious and Bitbucket are popular too.

Page 25: Git training with Devaamo

Exercise:- go to https://github.com/ottok/git-training and fork it- look at the fork under your own Github account and clone it to your laptop- edit names.txt and add yours- push changes back to Github- in Github, do a merge request back to me

Page 26: Git training with Devaamo

Want to put a simple shared repository on any SSH capable server? Create a bare .git with no working files:

git init --bare

Want to have notifications when somebody commits?Put a shell script at .git/hooks/post-receive

Page 27: Git training with Devaamo

5. Advanced commands

Page 28: Git training with Devaamo

Sorry, but default commands not very friendly, so get yourself good cheat cheets and write up your common

commands once you've figured them out..

Image credits Steve Bennet (http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/)

Page 29: Git training with Devaamo
Page 30: Git training with Devaamo

5. Git everywhere

Page 31: Git training with Devaamo

Would you like to store all your files in Git?Git-annex

Diff of binary files?Add in .git/config

[diff "odf"] textconv=odt2txt

See also: http://www-verimag.imag.fr/~moy/opendocument/

Page 32: Git training with Devaamo

Backup entire file systems with Git?Bup

https://github.com/apenwarr/bup

Bug tracker and wiki contents in Git?trac+git

Page 33: Git training with Devaamo

Publish to the web with one commit?gitblog

https://github.com/rsms/gitblog

Open source alternative to Dropbox based on Git?http://sparkleshare.org/

Page 34: Git training with Devaamo

Publish to the web with one commit?gitblog

https://github.com/rsms/gitblog

Open source alternative to Dropbox based on Git?http://sparkleshare.org/

Page 35: Git training with Devaamo

Would you like others to contribute to your software?

Provide easy forking (git clone), easy way to develop new feature (git branch),

and an easy way to send them back (merge request).

Page 36: Git training with Devaamo

Will Git credits replace developers CV's?

Page 37: Git training with Devaamo

Is there anything we can't store and track in Git?

Page 38: Git training with Devaamo

Recommended next reading:Pro Git for $25 on Amazon

Also online athttp://git-scm.com/book

This presentation will be available at seravo.fi/blog

Page 39: Git training with Devaamo

Contact Seravo Oy:n if you need Linux natives to develop and administer

your Linux systems

About the company: seravo.fiAbout the technologies: seravo.fi/blog