Let's do Git!

Let's do Git!

A session on Git by @ajithrnayak

4c21eb76541194ebc8eaa6852d5c2da4?s=128

Ajith R Nayak

February 27, 2015
Tweet

Transcript

  1. Let’s do Git! http://ajithrnayak.com <by> @ajithrnayak </by>

  2. History “I’m an egotistical bastard, and I name all my

    projects after myself. First Linux, now git.” Linus Torvalds Born in 2005 Projects Linux Kernel Android Fedora JQuery Eclipse Drupal millions more..
  3. Git? “Git is free and open source distributed version control

    system designed to handle everything from small to very large projects with speed and efficiency.”
  4. Git? “Git is free and open source distributed version control

    system designed to handle everything from small to very large projects with speed and efficiency.” “Directory Content Management System”
  5. Git? “Git is free and open source distributed version control

    system designed to handle everything from small to very large projects with speed and efficiency.” “Directory Content Management System” “A Stupid Content Tracker”
  6. Git? “Git is free and open source distributed version control

    system designed to handle everything from small to very large projects with speed and efficiency.” “Directory Content Management System” “A Stupid Content Tracker” “A Toolkit”
  7. Git is free and open source distributed version control system

    designed to handle everything from small to very large projects speed and efficiency. with Git?
  8. free and open source distributed version control system speed and

    efficiency. Git?
  9. Free & Open Source Downloads - It’s free http://git-scm.com/downloads Mac

    OS X, Windows, Linux & Solaris Source Code + Freedom https://github.com/git/git GNU General Public License Current Version : v2.3.0 (6/2/2015) GUI Clients Github, Gitbox, SourceTree GitX, GitEye, Tower Documentation http://git-scm.com/doc Book : Pro Git - Free PDF
  10. Version Control System No VCS?

  11. Version Control System Your project team?

  12. “A system that records changes to a file or set

    of files over time so that you can recall specific revisions later.” What is it? Version Control System
  13. Version Control System What’s in market?

  14. Version Control System Mercurial SVN Perforce CVS

  15. Version Control System Mercurial SVN Perforce CVS Git

  16. Distributed Local Version Control System

  17. Distributed v.3 v.2 File Local Computer Version DB v.1 Local

    Version Control System
  18. Distributed v.3 v.2 File Local Computer Version DB v.1 Local

    Version Control System Everything is LOCAL
  19. v.3 v.2 Version DB v.1 Centralized VCS File File Computer

    1 Computer 2 Central VCS Server Distributed
  20. v.3 v.2 Version DB v.1 Centralized VCS SERVER has master

    repo. File File Computer 1 Computer 2 Central VCS Server Distributed
  21. v.3 v.2 Version DB v.1 Centralized VCS SERVER has master

    repo. Collaborate with others on a different system File File Computer 1 Computer 2 Central VCS Server Distributed
  22. v.3 v.2 Version DB v.1 Centralized VCS SERVER has master

    repo. Collaborate with others on a different system We push everything to server. File File Computer 1 Computer 2 Central VCS Server Distributed
  23. Central VCS Server v.3 v.2 File Computer 1 Version DB

    v.1 v.3 v.2 Version DB v.1 v.3 v.2 File Computer 2 Version DB v.1 Distributed VCS Distributed
  24. Distributed VCS server has master repo, but you’ve a COPY

    (clone) of it on your machine. every clone is a BACKUP everything is LOCAL everything is FAST work OFFLINE Distributed
  25. No Network? No Problem! Committing Changes Viewing File History Performing

    a diff Merge/Switch branches Obtain any older version of file No .svn directories Speed & Efficiency
  26. Stream of Snapshots delta storage file B file C C

    1 C 2 C 3 C 4 C 5 snapshot storage file A file B file C file A ∆1 ∆2 ∆1 ∆2 ∆1 ∆2 ∆3 A1 B B A C2 A2 C1 C2 A2 B1 B2 C3
  27. 3 States Repository (.git directory) Staging Area (index) Working Directory

    (playground)
  28. 3 States Repository (.git directory) Staging Area (index) Working Directory

    (playground) Checkout the project Stage changes Commit Changes
  29. 3 States Repository (.git directory) Staging Area (index) Working Directory

    (playground) Local System
  30. Basic Git Flow Local System workspace .git repo stage/index

  31. Basic Git Flow Local System workspace .git repo stage/index Origin

    repository
  32. Basic Git Flow Local System workspace .git repo stage/index Origin

    repository add commit status clone pull fetch checkout push merge/revert
  33. Basic Git Flow Local System workspace .git repo stage/index stash

    Origin repository add commit status clone pull fetch checkout push merge/revert
  34. Basic Git Flow Local System workspace .git repo stage/index stash

    Origin repository add commit status clone pull fetch checkout save push apply/discard merge/revert
  35. Let’s do it

  36. .gitconfig $ git config --global user.name “Ajith” $ git config

    --global user.email yo@yo.com $ git config --global merge.tool FileMerge $ git config --global core.editor vim $ git config --global color.ui true Ahoy! Identify yourself Handy global settings
  37. .git $ git init Create a new repository E.g. $

    cd myProjectFolder $ touch hello_world.txt $ git init
  38. .git $ git init Create a new repository $ git

    clone <URL> Clone an existing repository E.g. $ cd myProjectFolder $ touch hello_world.txt $ git init E.g. $ git clone git@github.com:ajithrnayak/AJUtilities.git Cloning into 'AJUtilities'...
  39. The Primary Weapons

  40. $ git status Shows the Life cycle of files

  41. Life cycle of file

  42. $ git status $ git status # On branch master

    nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” $ git status -s Short status
  43. $ git status On branch master Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) m odified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) h ello_again.txt no changes added to commit (use "git add" and/or "git commit -a") $ git status $ git status # On branch master nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” $ git status -s Short status
  44. $ git status On branch master Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) m odified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) h ello_again.txt no changes added to commit (use "git add" and/or "git commit -a") $ git status $ git status # On branch master nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” $ git status -s Short status
  45. $ git status On branch master Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) m odified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) h ello_again.txt no changes added to commit (use "git add" and/or "git commit -a") $ git status $ git status # On branch master nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” $ git checkout - -hello_world.txt $ git status -s Short status
  46. $ git status On branch master Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) m odified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) h ello_again.txt no changes added to commit (use "git add" and/or "git commit -a") $ git status $ git status # On branch master nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” Unstaged $ git status -s Short status
  47. $ git status On branch master Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) m odified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) h ello_again.txt no changes added to commit (use "git add" and/or "git commit -a") $ git status $ git status # On branch master nothing to commit, working directory clean $ touch hello_again.txt Edit hello_world.txt with “git, why you so cool?” Untracked $ git status -s Short status
  48. $ git add Lets add file(s) to stage - Ready

    for commit $ git add hello_world.txt
  49. $ git add Lets add file(s) to stage - Ready

    for commit $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) hello_again.txt $ git add hello_world.txt
  50. $ git add Lets add file(s) to stage - Ready

    for commit $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) hello_again.txt $ git add hello_world.txt
  51. $ git add Lets add file(s) to stage - Ready

    for commit $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: hello_world.txt Untracked files: (use "git add <file>..." to include in what will be committed) hello_again.txt $ git add hello_world.txt $ git reset HEAD hello_world.txt Unstaged changes after reset: M hello_world.txt
  52. $ git add Lets add file(s) to stage - Ready

    for commit $ git add - -all $ git status On branch master On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) n ew file: hello_again.txt m odified: hello_world.txt
  53. $ git add Lets add file(s) to stage - Ready

    for commit Remember, tracking a new file starts after you add it Modified staged file? stage it again $ git add - -all $ git status On branch master On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) n ew file: hello_again.txt m odified: hello_world.txt
  54. $ git diff diff --git a/hello_world.txt b/hello_world.txt index e69de29..01c8652 100644

    --- a/hello_world.txt +++ b/hello_world.txt @@ -0,0 +1,3 @@ +Git, why you so cool ? + +Yay! $ git diff
  55. $ git diff diff --git a/hello_world.txt b/hello_world.txt index 01c8652..f643d9c 100644

    --- a/hello_world.txt +++ b/hello_world.txt @@ -1,3 +1,5 @@ Git, why you so cool ? -Yay! +Ask yourself. + +It seems that you committed twice. \ No newline at end of file $ git diff
  56. $ git diff diff --git a/hello_world.txt b/hello_world.txt index 01c8652..f643d9c 100644

    --- a/hello_world.txt +++ b/hello_world.txt @@ -1,3 +1,5 @@ Git, why you so cool ? -Yay! +Ask yourself. + +It seems that you committed twice. \ No newline at end of file $ git diff workspace Vs Index $ git diff HEAD workspace Vs last commit $ git diff - -staged staged Vs last commit $ git diff $commit1 $commit2 commit Vs commit $ git diff <branchName> current branch Vs another branch $ git diff
  57. Now, commit everything with appropriate “message” $ git commit $

    git commit -m 'hello again has a line'
 [master a76d160] hello again has a line
 1 file changed, 1 insertion(+)
  58. Now, commit everything with appropriate “message” shortcut $ git commit

    $ git commit -m 'hello again has a line'
 [master a76d160] hello again has a line
 1 file changed, 1 insertion(+) $ git commit -a -m ‘fixed a regex bug' [master b02bd27] fixed a regex bug 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 hello_again.txt
  59. Now, commit everything with appropriate “message” shortcut Changes that are

    staged/indexed are written to [.git] repository Gets a new SHA1 hashvalue The HEAD points to new commit Empty message aborts commit $ git commit - -amend show you the commit ? - $ git show $ git commit $ git commit -m 'hello again has a line'
 [master a76d160] hello again has a line
 1 file changed, 1 insertion(+) $ git commit -a -m ‘fixed a regex bug' [master b02bd27] fixed a regex bug 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 hello_again.txt
  60. $ git commit -m “Said hello to people" [master 91e5129]

    Said hello to people 2 files changed, 1 deletion(-) create mode 100644 hello_people.txt What’s happening under the hood? $ git commit
  61. $ git commit -m “Said hello to people" [master 91e5129]

    Said hello to people 2 files changed, 1 deletion(-) create mode 100644 hello_people.txt What’s happening under the hood? $ git commit
  62. $ git commit

  63. Object model commit blob tree Pointer to a 
 snapshot

    Directory
 list File
 contents
  64. $ git log $ git log
 commit a76d160f2964a7ed488c96550a474cb8e31d05d0 Author: Ajith

    <ajithr.nayak@mobinius.com> Date: Tue Feb 17 09:49:45 2015 +0530 hello again commit b02bd2733c90e72914e9ae7b861662a77bc50b22 Author: Ajith <ajithr.nayak@mobinius.com> Date: Tue Feb 17 09:36:27 2015 +0530 another exp commit commit 7c971151c8543ee99fcf60a7f839c74f8a91b055 Author: Ajith <ajithr.nayak@mobinius.com> Date: Tue Feb 17 09:34:17 2015 +0530 exp commit $ git log -3 shows last 3 commits $ git log - -since=2.days logs since last 2 days $ git log - -p patch with each commit $ git log - -pretty=oneline each commit on single line $ git log - -graph a cool graph A look back at all the commit logs
  65. $ git tag $ git tag List out all the

    existing tags $ git tag v.1.0.3 New tag is created- ‘v.1.0.3’ Lightweight tag $ git tag -a <name> -m “first official release” New tag with more info Annotated tag Tag is a named reference to a commit
  66. OMGit!! The Rescue weapons $ git revert <commit> Reverse Commit

    - Adds another commit by reverting the commit $ git commit - -ammend Alter Commit - Make changes to last commit $ git reset HEAD <file> Unstage file - Removes it from stage/index $ git checkout <file> Revert changes - commit Vs commit $ git rm Remove files - delete the file.
  67. OMGit!! Panic time!!

  68. OMGit!! Panic time!! $ git reflog a76d160 HEAD@{0}: commit: hello

    again b02bd27 HEAD@{1}: commit: another exp commit 7c97115 HEAD@{2}: commit: exp commit 2fa198e HEAD@{3}: commit: another commit 1d9b1ad HEAD@{4}: commit (initial): Initial commit
  69. OMGit!! Panic time!! $ git reset - -hard HEAD@{2} Be

    gone! - head, staged & workspace is erased reset flags: - -hard - -soft - -mixed $ git reflog a76d160 HEAD@{0}: commit: hello again b02bd27 HEAD@{1}: commit: another exp commit 7c97115 HEAD@{2}: commit: exp commit 2fa198e HEAD@{3}: commit: another commit 1d9b1ad HEAD@{4}: commit (initial): Initial commit
  70. .gitignore Ignore files that never needs tracking iOS e.g. .DS_Store

    .Trashes *.swp DerivedData build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 xcuserdata *.xccheckout E.g
 breakpoints, log files, project bundle state etc Check this out : http://github.com/github/gitignore
  71. Remote Adding a remote to your local repository $ git

    remote add https://github.com/ajithrnayak/epicStuff.git OR $ git remote add git@github.com/ajithrnayak/epicStuff.git
  72. Remote Adding a remote to your local repository Cloned a

    repo? It already has remote - origin $ git remote add https://github.com/ajithrnayak/epicStuff.git OR $ git remote add git@github.com/ajithrnayak/epicStuff.git $ git remote -v origin git@github.com/ajithrnayak/epicStuff.git(fetch) origin git@github.com/ajithrnayak/epicStuff.git(push)
  73. Remote Adding a remote to your local repository Cloned a

    repo? It already has remote - origin $ git remote add https://github.com/ajithrnayak/epicStuff.git OR $ git remote add git@github.com/ajithrnayak/epicStuff.git $ git remote -v origin git@github.com/ajithrnayak/epicStuff.git(fetch) origin git@github.com/ajithrnayak/epicStuff.git(push) Information about remote $ git remote show origin
  74. Push $ git push <remote_name> <remote_branch> E.g. $ git push

    origin master Push a branch to remote Push only the branches that you want to share Rejected if branch is behind $ git push origin - -tags Tags must be pushed seperately Push changes to remote
  75. Fetch Vs Pull Get data from others (remote repo) $

    git fetch <remote_name> Not available to workspace yet. $ git pull $ git fetch + $ git merge workspace .git repo stage/index stash repository pull fetch Local System Origin
  76. I n t e r m i s s i

    o n
  77. The Killer Weapon

  78. $ git branch A branch is a lightweight, movable POINTER

    to a commit The default branch is ‘master’ - never delete it! $ git branch * master
  79. $ git branch A branch is a lightweight, movable POINTER

    to a commit The default branch is ‘master’ - never delete it! $ git branch * master C 1 C 2 <branch name> HEAD Time
  80. $ git branch A branch is a lightweight, movable POINTER

    to a commit The default branch is ‘master’ - never delete it! $ git branch * master C 1 C 2 <branch name> HEAD Time Local pointer to your current branch
  81. $ git branch <branch name> Create a new branch C

    1 C 2 master HEAD $ git branch
  82. $ git branch <branch name> Create a new branch $

    git branch experiment Create a new branch named ‘experiment’ C 1 C 2 master HEAD $ git branch
  83. $ git branch <branch name> Create a new branch $

    git branch experiment Create a new branch named ‘experiment’ C 1 C 2 master HEAD experiment $ git branch 
 experiment * master $ git branch
  84. $ git checkout C 1 C 2 master experiment $

    git checkout <branch name> switch to the branch $ git checkout experiment Switched to branch ‘experiment' $ git branch master * experiment HEAD
  85. $ git checkout C 1 C 2 master experiment $

    git checkout <branch name> switch to the branch $ git checkout experiment Switched to branch ‘experiment' $ git branch master * experiment $ git checkout -b <branch name> create and switch to the branch Happens in a blink of an eye! Everything happens in your local machine HEAD
  86. How it works C 1 C 2 master experiment HEAD

  87. How it works $ git commit C 1 C 2

    master experiment HEAD
  88. C 3 How it works $ git commit C 1

    C 2 master experiment HEAD
  89. C 3 How it works $ git commit C 1

    C 2 master experiment HEAD
  90. C 3 How it works $ git commit $ git

    commit C 1 C 2 master experiment HEAD
  91. C 3 C 4 How it works $ git commit

    $ git commit C 1 C 2 master experiment HEAD
  92. C 3 C 4 How it works $ git commit

    $ git commit C 1 C 2 master experiment HEAD
  93. C 3 C 4 C 5 How it works $

    git commit $ git commit $ git commit C 1 C 2 master experiment HEAD
  94. C 3 C 4 C 5 How it works $

    git commit $ git commit $ git commit C 1 C 2 master experiment HEAD
  95. C 3 C 4 C 5 How it works $

    git commit $ git commit $ git checkout master $ git commit C 1 C 2 master experiment HEAD
  96. C 3 C 4 C 5 How it works $

    git commit $ git commit $ git checkout master $ git commit C 1 C 2 master experiment HEAD
  97. How it works C 1 C 2 master experiment $

    git checkout master HEAD C 3 C 4 C 5
  98. How it works C 1 C 2 master experiment $

    git checkout master HEAD $ git commit C 3 C 4 C 5
  99. How it works C 1 C 2 master experiment $

    git checkout master HEAD $ git commit C 6 C 3 C 4 C 5
  100. How it works C 1 C 2 master experiment $

    git checkout master HEAD $ git commit C 6 C 3 C 4 C 5
  101. How it works C 1 C 2 master experiment $

    git checkout master HEAD $ git commit C 6 C 3 C 4 C 5
  102. $ git merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5
  103. $ git merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5 $ git merge experiment
  104. $ git merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5 $ git merge experiment C 7
  105. $ git merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5 $ git merge experiment C 7
  106. $ git merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5 $ git merge experiment C 7 MAGIC! Delete ‘experiment’ branch
  107. None
  108. C 1 C 2 master experiment C 3 C 4

    HEAD C 6 C 5 3 -way merge
  109. 3 -way merge C 1 C 2 master experiment C

    3 C 4 HEAD C 6 C 5 C 7
  110. Fast Forward C 1 C 2 master experiment C 3

    C 4 HEAD C 5
  111. C 1 C 2 master experiment C 3 C 4

    HEAD C 5 Fast Forward
  112. C 1 C 2 master experiment C 3 C 4

    HEAD C 5 Fast Forward Use ‘- -no-ff’ for a non-fastforward merge Simply adds a commit that summarises merge
  113. Sometimes, no magic :( Merge conflicts

  114. Merge conflicts Sometimes, no magic :( $ git merge exp

    Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.
  115. Merge conflicts Sometimes, no magic :( $ git merge exp

    Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. $ git status On branch master You have unmerged paths. (fix conflicts and run "git commit”) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")
  116. Merge conflicts Sometimes, no magic :( $ git merge exp

    Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. $ git status On branch master You have unmerged paths. (fix conflicts and run "git commit”) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")
  117. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts
  118. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts
  119. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts
  120. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3
  121. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3 def hello <<<<<<< HEAD puts 'hola Amigos' ||||||| original puts 'hello Amigos' ======= puts 'hello world' >>>>>>> said hello to world end
  122. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3 def hello <<<<<<< HEAD puts 'hola Amigos' ||||||| original puts 'hello Amigos' ======= puts 'hello world' >>>>>>> said hello to world end
  123. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3 def hello <<<<<<< HEAD puts 'hola Amigos' ||||||| original puts 'hello Amigos' ======= puts 'hello world' >>>>>>> said hello to world end
  124. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3 def hello <<<<<<< HEAD puts 'hola Amigos' ||||||| original puts 'hello Amigos' ======= puts 'hello world' >>>>>>> said hello to world end
  125. def hello <<<<<<< HEAD puts ‘hola Amigos' ======= puts 'hello

    world' >>>>>>> said hello to world end Resolve conflicts $ git config --global merge.conflictstyle diff3 Use git mergetool Resolve conflicts Do a commit def hello <<<<<<< HEAD puts 'hola Amigos' ||||||| original puts 'hello Amigos' ======= puts 'hello world' >>>>>>> said hello to world end
  126. tl;dr $ git branch List all - list existing branches

    $ git branch <branch name> Create- creates a branch $ git branch -d <branch name> Delete - removes a branch $ git checkout <branch name> Switch - switches current branch $ git push <remote> <branch name> Push - pushing branch to remote $ git checkout -b <branchname> <remote_name>/ <branch name> Track- create a local branch of remote branch $ git branch - -delete <remote_name>/<branch name> Delete - removes a remote branch $ git branch -m <new_branch_name> Rename - renames current branch
  127. Git is cool Here’s why :

  128. Git is cool Here’s why : Cheap branching Everything is

    local It’s fast It’s small No blocked files Distributed No network Github & Bitbucket Huge community
  129. Git is super cool Here’s why :

  130. Git is super cool Workflow Capabilities Here’s why :

  131. Capabilities? Release Can we fix a bug for next release?

    Can we get the codes of last release? Build Can we build the current code? Can we ship a build to client? Feature Is that feature complete? Can we try implementing this feature? Hot fix Can we do a hot fix to current version? Review How everybody can review your code? Thank you, @svenpet
  132. Git workflows What can/should you do with branches Workflows in

    your development cycle Forking workflow github’s favourite Centralized workflow subversion like Feature Branch workflow new branch for every task/feature/story Git Flow workflow organise your source code
  133. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo
  134. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo Original 
 repo https://github.com/facebook/paper
  135. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo Original 
 repo Forked 
 repo fork https://github.com/facebook/paper https://github.com/ajithrnayak/paper
  136. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo Original 
 repo Forked 
 repo fork No push https://github.com/facebook/paper https://github.com/ajithrnayak/paper
  137. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo Original 
 repo Forked 
 repo fork No push https://github.com/facebook/paper https://github.com/ajithrnayak/paper
  138. Forking workflow Github’s favourite - open source process Makes a

    copy of a repo on the server You can’t push directly to original repo You can still get changes from original repo Original 
 repo Forked 
 repo fork No push pull request https://github.com/facebook/paper https://github.com/ajithrnayak/paper
  139. Centralized workflow Central 
 repo develop 
 repo develop 


    repo develop 
 repo develop 
 repo SVN users, this one is for you Decentralized but centralized You get a complete local copy Pull/Push changes very often +ve : Conflicts are dealt very soon -ve : unfinished stories
  140. Feature branch workflow Original 
 repo master branch per feature/story/task

  141. Feature branch workflow Original 
 repo master feature 1 branch

    per feature/story/task
  142. Feature branch workflow Original 
 repo master feature 1 branch

    per feature/story/task ’n’ developers can work on one branch
  143. Feature branch workflow Original 
 repo master feature 1 feature

    2 branch per feature/story/task ’n’ developers can work on one branch merge when its done & delete feaure branch
  144. Feature branch workflow Original 
 repo master feature 1 feature

    2 branch per feature/story/task ’n’ developers can work on one branch merge when its done & delete feaure branch
  145. Feature branch workflow Original 
 repo master branch per feature/story/task

    ’n’ developers can work on one branch merge when its done & delete feaure branch +ve : master is clean with complete features you work independently merge frequently; short stories.
  146. Git flow The Feast! Vincent Driessen

  147. Git flow The Feast! Vincent Driessen Branching strategy & release

    management A development model to manage software development process
  148. Codebase maintainer

  149. Git flow Decentralized but Centralized Each developer pulls/pushes to origin

    ‘Origin’ is central repo (for all git users) Origin Shiv AJ Pabi Arch
  150. Git flow Main branches; master & develop master Initial commit

  151. develop Git flow Main branches; master & develop master Initial

    commit
  152. develop Git flow Main branches; master & develop master Initial

    commit
  153. develop Git flow Main branches; master & develop master Initial

    commit
  154. develop Git flow Main branches; master & develop master Initial

    commit
  155. develop Git flow Main branches; master & develop master Initial

    commit version 1.O
  156. develop Git flow Main branches; master & develop master Initial

    commit version 1.O version 2.O
  157. develop Git flow Main branches; master & develop master Initial

    commit version 1.O version 2.O in-progress work for next release
  158. develop Git flow Main branches; master & develop Master’s HEAD

    - Release builds Create a ‘git tag’ for every release version Develop reflects ‘completed’ development changes master v_1.0 v_2.0
  159. develop Git flow Main branches; master & develop Master’s HEAD

    - Release builds Create a ‘git tag’ for every release version Develop reflects ‘completed’ development changes Git hook scripts to automate master v_1.0 v_2.0 Autobots,
 prepare for release!
  160. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop
  161. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature"
  162. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature"
  163. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature"
  164. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature"
  165. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature" $ git checkout develop
  166. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature" $ git checkout develop $ git merge - -no-ff myfeature
  167. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop feature 1 >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature" $ git checkout develop $ git merge - -no-ff myfeature
  168. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature" $ git checkout develop $ git merge - -no-ff myfeature $ git branch -d myfeature
  169. Git flow That’s release Mgmt; Now, developer’s snack! Let’s build

    features/stories/tasks Feature Branches develop >_ $ git checkout -b myfeature develop Switched to a new branch “myfeature" $ git checkout develop $ git merge - -no-ff myfeature $ git branch -d myfeature $ git push origin develop
  170. Git flow Nasty bugs on current deployed version; Yikes! Hotfix

    branches develop master v_1.0
  171. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix
  172. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix
  173. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix
  174. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix v_1.1
  175. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix v_1.1
  176. develop master v_1.0 Git flow Nasty bugs on current deployed

    version; Yikes! Hotfix branches hotfix v_1.1
  177. Power UPs!

  178. $ git rebase Alternative to merging Reapply introduced changes on

    top of another commit Avoid merge commits for pulling Keeps history clean Be Carefull !! origin feature 1 feature 1
  179. $ git rebase Alternative to merging Reapply introduced changes on

    top of another commit Avoid merge commits for pulling Keeps history clean Be Carefull !! Commits to be pushed and pulled? fetch + rebase & push origin feature 1 feature 1
  180. Stash Local System workspace stash save apply/discard

  181. Stash Local System workspace stash save apply/discard “On hold” stuff

    Reset staging area & workspace Changes are cached $ git stash save “description” reset index and workspace $ git stash list all your stashes $ git stash apply get them back - apply $ git stash pop apply and drop
  182. Cherrypick pick changes from another commit
 A new commit is

    added on top of HEAD origin feature 1 feature 1 develop
  183. Cherrypick pick changes from another commit
 A new commit is

    added on top of HEAD origin feature 1 feature 1 develop
  184. Code review Why do you want code reviews? - Let’s

    ask the birdies!
  185. Code review Why do you want code reviews? Learn Code

    Quality Blame Feels Good - Let’s ask the birdies!
  186. Code review How does it work?

  187. Code review How does it work? Send ‘pull request’ ’n’

    members can review your code at the same time Commit messages should explain changes introduced in each commit Others can improve your code Happy birds!!
  188. Help?

  189. Help? $ git help <command> Google is your best buddy!

    Refer documentation - Be a Pro!
  190. Help? $ git help <command> Google is your best buddy!

    Refer documentation - Be a Pro! Or, pay for my beer ;-)
  191. One more thing..

  192. One more thing.. Github && Bitbucket && Gitlab

  193. Behold, questions!

  194. Holy! whackamoly!

  195. Holy! whackamoly! Now, Go Git it..