Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git - introduction

Git - introduction

Tymon Tobolski

March 30, 2013
Tweet

More Decks by Tymon Tobolski

Other Decks in Programming

Transcript

  1. Konfiguracja ~ $ git config --global user.name ”Tymon Tobolski” ~

    $ git config --global user.email ”[email protected]” Wednesday, 23 February 2011
  2. 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
  3. 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
  4. 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
  5. git init ~ $ mkdir ilabs ~ $ cd ilabs

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

    ~/ilabs $ git init Initialized empty Git repository in /Users/teamon/ilabs/.git/ Wednesday, 23 February 2011
  7. 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
  8. 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
  9. 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) # #! README nothing added to commit but untracked files present (use "git add" to track) Wednesday, 23 February 2011
  10. 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 # Wednesday, 23 February 2011
  11. 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
  12. 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
  13. git log ~/ilabs $ git log commit 28dc8e941ac55657cc633575967a7e72dd3ea898 Author: Tymon

    Tobolski <[email protected]> Date: Sun May 2 15:23:58 2010 +0200 First commit Wednesday, 23 February 2011
  14. git log ~/ilabs $ git log commit 66c61ef16075eccbfd4f015e3e12c6c5f87c29d0 Author: Tymon

    Tobolski <[email protected]> Date: Sun May 2 15:51:53 2010 +0200 Next one commit 595ae522a0b115535f166813e31538b4f7119013 Author: Tymon Tobolski <[email protected]> Date: Sun May 2 15:51:40 2010 +0200 Second commit commit 28dc8e941ac55657cc633575967a7e72dd3ea898 Author: Tymon Tobolski <[email protected]> Date: Sun May 2 15:23:58 2010 +0200 First commit Wednesday, 23 February 2011
  15. 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
  16. git branch c1 c2 c3 c4 master c6 feature c5

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

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

    $ git branch feature * master ~/ilabs $ git checkout feature Switched to branch 'feature' Wednesday, 23 February 2011
  19. 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
  20. git branch / checkout git branch feature git checkout feature

    == git checkout -b feature Wednesday, 23 February 2011
  21. git merge c3 c4 master c6 feature c5 ... ...

    c7 master Wednesday, 23 February 2011
  22. git merge c4 c6 c7 SHA: 81f23...b9942 SHA: 9dc8d...d497f SHA:

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

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

    8f06c...20e83 PARENT: 81f23...b9942 PARENT: 9dc8d...d497f Wednesday, 23 February 2011
  25. git merge ~/ilabs $ git checkout master Switched to branch

    'master' Wednesday, 23 February 2011
  26. 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
  27. git stash ~/ilabs $ git stash Switched to branch 'master'

    ~/ilabs $ echo "666" >> README Wednesday, 23 February 2011
  28. 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 <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") Wednesday, 23 February 2011
  29. 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
  30. 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
  31. 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
  32. 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") Wednesday, 23 February 2011
  33. 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 asd 666 Wednesday, 23 February 2011
  34. 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
  35. git remote ~ $ cd synergio ~/synergio $ git remote

    origin Wednesday, 23 February 2011
  36. 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
  37. 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
  38. 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