Slide 1

Slide 1 text

git Podstawy Tymon Tobolski Ko!o Naukowe iLabs Politechnika Wroc!awska Wednesday, 23 February 2011

Slide 2

Slide 2 text

Dlaczego git? Wednesday, 23 February 2011

Slide 3

Slide 3 text

Wednesday, 23 February 2011

Slide 4

Slide 4 text

Instalacja Wednesday, 23 February 2011

Slide 5

Slide 5 text

albo... $ sudo port install git-core Wednesday, 23 February 2011 $ brew install git

Slide 6

Slide 6 text

Konfiguracja ~ $ git config --global user.name ”Tymon Tobolski” ~ $ git config --global user.email ”[email protected]” Wednesday, 23 February 2011

Slide 7

Slide 7 text

Konfiguracja ~ $ git config --global user.name ”Tymon Tobolski” ~ $ git config --global user.email ”[email protected]” ~ $ cat .gitconfig [user] ! name = Tymon Tobolski ! email = [email protected] Wednesday, 23 February 2011

Slide 8

Slide 8 text

Komendy add am annotate apply applymbox applypatch archimport archive bisect blame branch cat-file check-attr check-ref-format checkout checkout-index cherry cherry-pick clean clone clone-pack commit commit-tree config convert-objects count-objects cvsexportcommit cvsimport describe diff diff-files diff-index diff-stages diff-tree fetch fetch-pack for-each-ref format-patch fsck gc get-tar-commit-id grep hash-object imap-send index-pack init instaweb local-fetch log lost-found ls-files ls-remote ls-tree mailinfo mailsplit merge merge-base merge-file merge-index merge-tree mergetool mktag mktree mv name-rev pack-objects pack-redundant pack-refs parse-remote patch-id peek-remote prune prune-packed pull push quiltimport read-tree rebase reflog relink remote repack request-pull rerere reset rev-list revert rm send-email shortlog show show-branch show-index show-ref stash status svn svnimport symbolic-ref tag tar-tree unpack-file unpack-objects update-index update-ref update-server-info var verify-pack verify-tag whatchanged write-tree Wednesday, 23 February 2011

Slide 9

Slide 9 text

Komendy add am annotate apply applymbox applypatch archimport archive bisect blame branch cat-file check-attr check-ref-format checkout checkout-index cherry cherry-pick clean clone clone-pack commit commit-tree config convert-objects count-objects cvsexportcommit cvsimport describe diff diff-files diff-index diff-stages diff-tree fetch fetch-pack for-each-ref format-patch fsck gc get-tar-commit-id grep hash-object imap-send index-pack init instaweb local-fetch log lost-found ls-files ls-remote ls-tree mailinfo mailsplit merge merge-base merge-file merge-index merge-tree mergetool mktag mktree mv name-rev pack-objects pack-redundant pack-refs parse-remote patch-id peek-remote prune prune-packed pull push quiltimport read-tree rebase reflog relink remote repack request-pull rerere reset rev-list revert rm send-email shortlog show show-branch show-index show-ref stash status svn svnimport symbolic-ref tag tar-tree unpack-file unpack-objects update-index update-ref update-server-info var verify-pack verify-tag whatchanged write-tree Wednesday, 23 February 2011

Slide 10

Slide 10 text

git init ~ $ mkdir ilabs ~ $ cd ilabs Wednesday, 23 February 2011

Slide 11

Slide 11 text

git init ~ $ mkdir ilabs ~ $ cd ilabs ~/ilabs $ git init Initialized empty Git repository in /Users/teamon/ilabs/.git/ Wednesday, 23 February 2011

Slide 12

Slide 12 text

git init ~/ilabs $ ls -la total 0 drwxr-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 ! Wednesday, 23 February 2011

Slide 13

Slide 13 text

Katalog roboczy Staging area Repozytorium git add git commit edycja Wednesday, 23 February 2011

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

git status ~/ilabs $ echo "KN iLabs" > README Wednesday, 23 February 2011

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

git add ~/ilabs $ git add README Wednesday, 23 February 2011

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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 Wednesday, 23 February 2011

Slide 20

Slide 20 text

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 master nothing to commit (working directory clean) Wednesday, 23 February 2011

Slide 21

Slide 21 text

git log ~/ilabs $ git log commit 28dc8e941ac55657cc633575967a7e72dd3ea898 Author: Tymon Tobolski Date: Sun May 2 15:23:58 2010 +0200 First commit Wednesday, 23 February 2011

Slide 22

Slide 22 text

git log ~/ilabs $ git log commit 66c61ef16075eccbfd4f015e3e12c6c5f87c29d0 Author: Tymon Tobolski Date: Sun May 2 15:51:53 2010 +0200 Next one commit 595ae522a0b115535f166813e31538b4f7119013 Author: Tymon Tobolski Date: Sun May 2 15:51:40 2010 +0200 Second commit commit 28dc8e941ac55657cc633575967a7e72dd3ea898 Author: Tymon Tobolski Date: Sun May 2 15:23:58 2010 +0200 First commit Wednesday, 23 February 2011

Slide 23

Slide 23 text

Workflow c1 c2 c3 MESSAGE: First commit SHA: 28dc8e941ac55657cc633575967a7e72dd3ea898 MESSAGE: Second commit SHA: 595ae522a0b115535f166813e31538b4f7119013 PARENT: 28dc8e941ac55657cc633575967a7e72dd3ea898 MESSAGE: Next one SHA: 66c61ef16075eccbfd4f015e3e12c6c5f87c29d0 PARENT: 595ae522a0b115535f166813e31538b4f7119013 Wednesday, 23 February 2011

Slide 24

Slide 24 text

git branch Wednesday, 23 February 2011

Slide 25

Slide 25 text

git branch c1 c2 c3 c4 master c6 feature c5 Wednesday, 23 February 2011

Slide 26

Slide 26 text

git branch / checkout ~/ilabs $ git branch feature Wednesday, 23 February 2011

Slide 27

Slide 27 text

git branch / checkout ~/ilabs $ git branch feature ~/ilabs $ git branch feature * master Wednesday, 23 February 2011

Slide 28

Slide 28 text

git branch / checkout ~/ilabs $ git branch feature ~/ilabs $ git branch feature * master ~/ilabs $ git checkout feature Switched to branch 'feature' Wednesday, 23 February 2011

Slide 29

Slide 29 text

git branch / checkout ~/ilabs $ git branch feature ~/ilabs $ git branch feature * master ~/ilabs $ git checkout feature Switched to branch 'feature' ~/ilabs $ git branch * feature master Wednesday, 23 February 2011

Slide 30

Slide 30 text

git branch / checkout git branch feature git checkout feature == git checkout -b feature Wednesday, 23 February 2011

Slide 31

Slide 31 text

git merge Wednesday, 23 February 2011

Slide 32

Slide 32 text

git merge Wednesday, 23 February 2011

Slide 33

Slide 33 text

git merge c3 c4 master c6 feature c5 ... ... c7 master Wednesday, 23 February 2011

Slide 34

Slide 34 text

git merge c4 c6 c7 SHA: 81f23...b9942 SHA: 9dc8d...d497f SHA: 8f06c...20e83 Wednesday, 23 February 2011

Slide 35

Slide 35 text

git merge c4 c6 c7 SHA: 81f23...b9942 SHA: 9dc8d...d497f SHA: 8f06c...20e83 PARENT: 81f23...b9942 Wednesday, 23 February 2011

Slide 36

Slide 36 text

git merge c4 c6 c7 SHA: 81f23...b9942 SHA: 9dc8d...d497f SHA: 8f06c...20e83 PARENT: 81f23...b9942 PARENT: 9dc8d...d497f Wednesday, 23 February 2011

Slide 37

Slide 37 text

git merge ~/ilabs $ git checkout master Switched to branch 'master' Wednesday, 23 February 2011

Slide 38

Slide 38 text

git merge ~/ilabs $ git checkout master Switched to branch 'master' ~/ilabs $ git merge feature Merge made by recursive. 1 files changed, 1 insertions(+), 0 deletions(-) Wednesday, 23 February 2011

Slide 39

Slide 39 text

git stash ~/ilabs $ git stash Switched to branch 'master' Wednesday, 23 February 2011

Slide 40

Slide 40 text

git stash ~/ilabs $ git stash Switched to branch 'master' ~/ilabs $ echo "666" >> README Wednesday, 23 February 2011

Slide 41

Slide 41 text

git stash ~/ilabs $ git stash Switched to branch 'master' ~/ilabs $ echo "666" >> README ~/ilabs $ git status # On branch master # Changed but not updated: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # #! modified: README # no changes added to commit (use "git add" and/or "git commit - a") Wednesday, 23 February 2011

Slide 42

Slide 42 text

git stash ~/ilabs $ cat README asd 666 Wednesday, 23 February 2011

Slide 43

Slide 43 text

git stash ~/ilabs $ cat README asd 666 ~/ilabs $ git stash Saved working directory and index state WIP on master: 992f518 Merge branch 'foo' HEAD is now at 992f518 Merge branch 'foo' Wednesday, 23 February 2011

Slide 44

Slide 44 text

git stash ~/ilabs $ cat README asd 666 ~/ilabs $ git stash Saved 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 master nothing to commit (working directory clean) Wednesday, 23 February 2011

Slide 45

Slide 45 text

git stash ~/ilabs $ cat README asd 666 ~/ilabs $ git stash Saved 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 master nothing to commit (working directory clean) ~/ilabs $ cat README asd Wednesday, 23 February 2011

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

Remote Wednesday, 23 February 2011

Slide 49

Slide 49 text

github Wednesday, 23 February 2011

Slide 50

Slide 50 text

github Wednesday, 23 February 2011

Slide 51

Slide 51 text

git clone ~ $ git clone [email protected]:teamon/synergio.git Wednesday, 23 February 2011

Slide 52

Slide 52 text

git clone ~ $ git clone [email protected]:teamon/synergio.git Initialized 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. Wednesday, 23 February 2011

Slide 53

Slide 53 text

git remote ~ $ cd synergio ~/synergio $ git remote origin Wednesday, 23 February 2011

Slide 54

Slide 54 text

git remote ~ $ cd synergio ~/synergio $ git remote origin ~/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) Wednesday, 23 February 2011

Slide 55

Slide 55 text

git push ~/synergio $ git push origin master Counting 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 Wednesday, 23 February 2011

Slide 56

Slide 56 text

git pull ~/synergio $ git pull origin master From github.com:teamon/synergio * branch master -> FETCH_HEAD Removing resources/app_j.js Merge made by recursive. resources/app_j.js | 201 ---------------------------------------------------- 1 files changed, 0 insertions(+), 201 deletions(-) delete mode 100644 resources/app_j.js Wednesday, 23 February 2011

Slide 57

Slide 57 text

GitX Wednesday, 23 February 2011

Slide 58

Slide 58 text

GitX • http://gitx.frim.nl - wersja stabilna • http://brotherbard.com/blog/2010/03/ experimental-gitx-fork/ Wednesday, 23 February 2011

Slide 59

Slide 59 text

Prezentacja do pobrania http://s.teamon.eu/Git.pdf Wednesday, 23 February 2011