59
git Podstawy Tymon Tobolski Koło Naukowe iLabs Politechnika Wrocławska wtorek, 11 maja 2010

Git-podstawy

Embed Size (px)

DESCRIPTION

Prezentacja z Koła Naukowego iLabs na PWr

Citation preview

Page 1: Git-podstawy

gitPodstawy

Tymon TobolskiKoło Naukowe iLabs

Politechnika Wrocławska

wtorek, 11 maja 2010

Page 2: Git-podstawy

Dlaczego git?

wtorek, 11 maja 2010

Page 3: Git-podstawy

wtorek, 11 maja 2010

Page 4: Git-podstawy

Instalacja

wtorek, 11 maja 2010

Page 5: Git-podstawy

albo...

$ sudo port install git-core

wtorek, 11 maja 2010

Page 6: Git-podstawy

Konfiguracja

~ $ git config --global user.name ”Tymon Tobolski”~ $ git config --global user.email ”[email protected]

wtorek, 11 maja 2010

Page 7: Git-podstawy

Konfiguracja

~ $ git config --global user.name ”Tymon Tobolski”~ $ git config --global user.email ”[email protected]

~ $ cat .gitconfig[user]! name = Tymon Tobolski! email = [email protected]

wtorek, 11 maja 2010

Page 8: Git-podstawy

Komendyaddam

annotateapply

applymboxapplypatcharchimport

archivebisectblamebranchcat-file

check-attrcheck-ref-format

checkoutcheckout-index

cherrycherry-pick

clean

clone clone-pack

commitcommit-tree

configconvert-objectscount-objects

cvsexportcommitcvsimportdescribe

diffdiff-files

diff-indexdiff-stagesdiff-tree

fetchfetch-packfor-each-refformat-patch

fsckgc

get-tar-commit-idgrep

hash-objectimap-sendindex-pack

initinstaweb

local-fetchlog

lost-foundls-files

ls-remotels-treemailinfomailsplitmerge

merge-base

merge-filemerge-indexmerge-tree mergetool

mktagmktree

mvname-rev

pack-objectspack-redundant

pack-refsparse-remote

patch-idpeek-remote

pruneprune-packed

pullpush

quiltimportread-tree

rebasereflogrelink

remoterepack

request-pullrererereset

rev-listrevert

rmsend-emailshortlog

showshow-branchshow-index

show-refstashstatussvn

svnimportsymbolic-ref

tag tar-tree

unpack-fileunpack-objectsupdate-indexupdate-ref

update-server-infovar

verify-packverify-tag

whatchangedwrite-tree

wtorek, 11 maja 2010

Page 9: Git-podstawy

Komendyaddam

annotateapply

applymboxapplypatcharchimport

archivebisectblamebranchcat-file

check-attrcheck-ref-format

checkoutcheckout-index

cherrycherry-pick

clean

clone clone-pack

commitcommit-tree

configconvert-objectscount-objects

cvsexportcommitcvsimportdescribe

diffdiff-files

diff-indexdiff-stagesdiff-tree

fetchfetch-packfor-each-refformat-patch

fsckgc

get-tar-commit-idgrep

hash-objectimap-sendindex-pack

initinstaweb

local-fetchlog

lost-foundls-files

ls-remotels-treemailinfomailsplitmerge

merge-base

merge-filemerge-indexmerge-tree mergetool

mktagmktree

mvname-rev

pack-objectspack-redundant

pack-refsparse-remote

patch-idpeek-remote

pruneprune-packed

pullpush

quiltimportread-tree

rebasereflogrelink

remoterepack

request-pullrererereset

rev-listrevert

rmsend-emailshortlog

showshow-branchshow-index

show-refstashstatussvn

svnimportsymbolic-ref

tag tar-tree

unpack-fileunpack-objectsupdate-indexupdate-ref

update-server-infovar

verify-packverify-tag

whatchangedwrite-tree

wtorek, 11 maja 2010

Page 10: Git-podstawy

git init

~ $ mkdir ilabs~ $ cd ilabs

wtorek, 11 maja 2010

Page 11: Git-podstawy

git init

~ $ mkdir ilabs~ $ cd ilabs~/ilabs $ git initInitialized empty Git repository in /Users/teamon/ilabs/.git/

wtorek, 11 maja 2010

Page 12: Git-podstawy

git init

~/ilabs $ ls -latotal 0drwxr-xr-x 3 teamon staff 102 2 maj 15:02 ./drwxr-xr-x+ 72 teamon staff 2448 2 maj 15:02 ../drwxr-xr-x 11 teamon staff 374 2 maj 15:05 .git/

Nie ma folderow .svn !

wtorek, 11 maja 2010

Page 13: Git-podstawy

Katalog roboczy

Staging area

Repozytorium

git add

git commit

edycja

wtorek, 11 maja 2010

Page 14: Git-podstawy

git status

~/ilabs $ git status# On branch master## Initial commit#nothing to commit (create/copy files and use "git add" to track)

wtorek, 11 maja 2010

Page 15: Git-podstawy

git status

~/ilabs $ echo "KN iLabs" > README

wtorek, 11 maja 2010

Page 16: Git-podstawy

git status

~/ilabs $ echo "KN iLabs" > README~/ilabs $ git status# On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in what will be committed)##! READMEnothing added to commit but untracked files present (use "git add" to track)

wtorek, 11 maja 2010

Page 17: Git-podstawy

git add

~/ilabs $ git add README

wtorek, 11 maja 2010

Page 18: Git-podstawy

git add

~/ilabs $ git add README~/ilabs $ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." to unstage)##! new file: README#

wtorek, 11 maja 2010

Page 19: Git-podstawy

git commit

~/ilabs $ git commit -m "First commit"[master (root-commit) 28dc8e9] First commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README

wtorek, 11 maja 2010

Page 20: Git-podstawy

git commit

~/ilabs $ git commit -m "First commit"[master (root-commit) 28dc8e9] First commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README

~/ilabs $ git status# On branch masternothing to commit (working directory clean)

wtorek, 11 maja 2010

Page 21: Git-podstawy

git log

~/ilabs $ git logcommit 28dc8e941ac55657cc633575967a7e72dd3ea898Author: Tymon Tobolski <[email protected]>Date: Sun May 2 15:23:58 2010 +0200

First commit

wtorek, 11 maja 2010

Page 22: Git-podstawy

git log~/ilabs $ git logcommit 66c61ef16075eccbfd4f015e3e12c6c5f87c29d0Author: Tymon Tobolski <[email protected]>Date: Sun May 2 15:51:53 2010 +0200

Next one

commit 595ae522a0b115535f166813e31538b4f7119013Author: Tymon Tobolski <[email protected]>Date: Sun May 2 15:51:40 2010 +0200

Second commit

commit 28dc8e941ac55657cc633575967a7e72dd3ea898Author: Tymon Tobolski <[email protected]>Date: Sun May 2 15:23:58 2010 +0200

First commit

wtorek, 11 maja 2010

Page 23: Git-podstawy

Workflow

c1

c2

c3

MESSAGE: First commit SHA: 28dc8e941ac55657cc633575967a7e72dd3ea898

MESSAGE: Second commit SHA: 595ae522a0b115535f166813e31538b4f7119013 PARENT: 28dc8e941ac55657cc633575967a7e72dd3ea898

MESSAGE: Next one SHA: 66c61ef16075eccbfd4f015e3e12c6c5f87c29d0 PARENT: 595ae522a0b115535f166813e31538b4f7119013

wtorek, 11 maja 2010

Page 24: Git-podstawy

git branch

wtorek, 11 maja 2010

Page 25: Git-podstawy

git branch

c1 c2 c3 c4 master

c6 featurec5

wtorek, 11 maja 2010

Page 26: Git-podstawy

git branch / checkout~/ilabs $ git branch feature

wtorek, 11 maja 2010

Page 27: Git-podstawy

git branch / checkout~/ilabs $ git branch feature

~/ilabs $ git branch feature* master

wtorek, 11 maja 2010

Page 28: Git-podstawy

git branch / checkout~/ilabs $ git branch feature

~/ilabs $ git branch feature* master

~/ilabs $ git checkout featureSwitched to branch 'feature'

wtorek, 11 maja 2010

Page 29: Git-podstawy

git branch / checkout~/ilabs $ git branch feature

~/ilabs $ git branch feature* master

~/ilabs $ git checkout featureSwitched to branch 'feature'

~/ilabs $ git branch* feature master

wtorek, 11 maja 2010

Page 30: Git-podstawy

git branch / checkout

git branch featuregit checkout feature

==

git checkout -b feature

wtorek, 11 maja 2010

Page 31: Git-podstawy

git merge

wtorek, 11 maja 2010

Page 32: Git-podstawy

git merge

wtorek, 11 maja 2010

Page 33: Git-podstawy

git merge

c3 c4master

c6feature c5

...

...

c7 master

wtorek, 11 maja 2010

Page 34: Git-podstawy

git merge

c4 c6

c7

SHA: 81f23...b9942 SHA: 9dc8d...d497f

SHA: 8f06c...20e83

wtorek, 11 maja 2010

Page 35: Git-podstawy

git merge

c4 c6

c7

SHA: 81f23...b9942 SHA: 9dc8d...d497f

SHA: 8f06c...20e83PARENT: 81f23...b9942

wtorek, 11 maja 2010

Page 36: Git-podstawy

git merge

c4 c6

c7

SHA: 81f23...b9942 SHA: 9dc8d...d497f

SHA: 8f06c...20e83PARENT: 81f23...b9942PARENT: 9dc8d...d497f

wtorek, 11 maja 2010

Page 37: Git-podstawy

git merge

~/ilabs $ git checkout masterSwitched to branch 'master'

wtorek, 11 maja 2010

Page 38: Git-podstawy

git merge

~/ilabs $ git checkout masterSwitched to branch 'master'

~/ilabs $ git merge featureMerge made by recursive.1 files changed, 1 insertions(+), 0 deletions(-)

wtorek, 11 maja 2010

Page 39: Git-podstawy

git stash~/ilabs $ git stashSwitched to branch 'master'

wtorek, 11 maja 2010

Page 40: Git-podstawy

git stash~/ilabs $ git stashSwitched to branch 'master'

~/ilabs $ echo "666" >> README

wtorek, 11 maja 2010

Page 41: Git-podstawy

git stash~/ilabs $ git stashSwitched to branch 'master'

~/ilabs $ echo "666" >> README

~/ilabs $ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)##! modified: README#no changes added to commit (use "git add" and/or "git commit -a")

wtorek, 11 maja 2010

Page 42: Git-podstawy

git stash~/ilabs $ cat READMEasd666

wtorek, 11 maja 2010

Page 43: Git-podstawy

git stash~/ilabs $ cat READMEasd666

~/ilabs $ git stashSaved working directory and index state WIP on master: 992f518 Merge branch 'foo'HEAD is now at 992f518 Merge branch 'foo'

wtorek, 11 maja 2010

Page 44: Git-podstawy

git stash~/ilabs $ cat READMEasd666

~/ilabs $ git stashSaved working directory and index state WIP on master: 992f518 Merge branch 'foo'HEAD is now at 992f518 Merge branch 'foo'

~/ilabs $ git status# On branch masternothing to commit (working directory clean)

wtorek, 11 maja 2010

Page 45: Git-podstawy

git stash~/ilabs $ cat READMEasd666

~/ilabs $ git stashSaved working directory and index state WIP on master: 992f518 Merge branch 'foo'HEAD is now at 992f518 Merge branch 'foo'

~/ilabs $ git status# On branch masternothing to commit (working directory clean)

~/ilabs $ cat READMEasd

wtorek, 11 maja 2010

Page 46: Git-podstawy

git stash~/ilabs $ git stash apply# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)##! modified: README#no changes added to commit (use "git add" and/or "git commit -a")

wtorek, 11 maja 2010

Page 47: Git-podstawy

git stash~/ilabs $ git stash apply# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)##! modified: README#no changes added to commit (use "git add" and/or "git commit -a")

~/ilabs $ cat README asd666

wtorek, 11 maja 2010

Page 48: Git-podstawy

Remote

wtorek, 11 maja 2010

Page 49: Git-podstawy

github

wtorek, 11 maja 2010

Page 50: Git-podstawy

github

wtorek, 11 maja 2010

Page 51: Git-podstawy

git clone~ $ git clone [email protected]:teamon/synergio.git

wtorek, 11 maja 2010

Page 52: Git-podstawy

git clone~ $ git clone [email protected]:teamon/synergio.gitInitialized empty Git repository in /Users/teamon/Desktop/synergio/.git/remote: Counting objects: 140, done.remote: Compressing objects: 100% (129/129), done.remote: Total 140 (delta 64), reused 0 (delta 0)Receiving objects: 100% (140/140), 159.13 KiB | 99 KiB/s, done.Resolving deltas: 100% (64/64), done.

wtorek, 11 maja 2010

Page 53: Git-podstawy

git remote~ $ cd synergio~/synergio $ git remoteorigin

wtorek, 11 maja 2010

Page 54: Git-podstawy

git remote~ $ cd synergio~/synergio $ git remoteorigin

~/synergio $ git remote show origin* remote origin Fetch URL: [email protected]:teamon/synergio.git Push URL: [email protected]:teamon/synergio.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (fast forwardable)

wtorek, 11 maja 2010

Page 55: Git-podstawy

git push

~/synergio $ git push origin masterCounting objects: 5, done.Delta compression using up to 2 threads.Compressing objects: 100% (3/3), done.Writing objects: 100% (3/3), 287 bytes, done.Total 3 (delta 2), reused 0 (delta 0)To [email protected]:teamon/synergio.git 4826a55..fd8157e master -> master

wtorek, 11 maja 2010

Page 56: Git-podstawy

git pull

~/synergio $ git pull origin masterFrom github.com:teamon/synergio * branch master -> FETCH_HEADRemoving resources/app_j.jsMerge made by recursive. resources/app_j.js | 201 ---------------------------------------------------- 1 files changed, 0 insertions(+), 201 deletions(-) delete mode 100644 resources/app_j.js

wtorek, 11 maja 2010

Page 57: Git-podstawy

GitX

wtorek, 11 maja 2010

Page 59: Git-podstawy

Prezentacja do pobrania

http://s.teamon.eu/Git.pdf

wtorek, 11 maja 2010