SlideShare a Scribd company logo
1 of 26
Download to read offline
Git .
Why, How, and more
@gargrag | correo@gaston.com.uy
PM -> track working
PM -> control the team
PM -> interact with the process.
PM -> know wich issues is the team working on.
DEV -> co-work
DEV -> rollback
DEV -> manipulate changes
DEV -> parallel versions
SUP -> know what code is deployed
SUP -> see which are the latest changes
SUP -> pull request some easy issues
Why Git ?
● remotes
● commits
● tags
● branches
● local / remote
Basic explanation
Good practices .
keep calm and take control
Commit often
Git can control only the code you commit, so commit
early and often, that's the way to have your code under
control and backed up.
Be reversible
Make commits atomically, use all the git potencial, to
make commits clear, by feature and reversible.
Git has all you need to commit changes grouped by
each, fix/feature you code.
Make clear and useful commit msgs
Besides making reversible, and atomic commits, ship
they with descriptive messages, so other teammates can
know exactly what each commit is about (especially
under stress)
Divide and conquer
If your code goes too large, divide it in repos by modules
or something depending on the software architecture
you are on.
You can use either submodules or separate repositories.
Get updated
Pull often, and before start working.
Remember your workflow
We have defined a workflow, remember it, and act
accord.
Be ware of changing public history
Git allows you to change the published history, but it can
be an annoyance for your teammates.
Better, fix the things by doing commits, maybe by revert,
or patching, etc. But going forward.
Don't freak
All your code is under control, any change is rollback-
able, any non - recursive merge, can be done with ease.
keep calm, things can look nasty, but belive me, is
simple.
Use a custom prompt
Use a custom unix prompt, that shows you info about
the repo you are working with, the branch you are, the
status and more things.
export PS1='[u@h W$(__git_ps1 " (%s)")]$ '
git has some ps1 variables and functions you can set up,
and if you prefer something more sophisticated take a
look at:
● https://github.com/nojhan/liquidprompt
● https://github.com/bpinto/oh-my-fish
Maintain your repo
Do some maintenance, sure someone has versioned a
mysql dump, and your repo is growing insanely. Take
care of that, and maintain the repo often.
Repack, delete weight files, and put order.
Rtfm!
and take some practice.
● http://pcottle.github.io/learnGitBranching/
● http://git-scm.com/book/ch3-4.html
● https://www.codeschool.com/courses/try-git
● https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+101
Basic commands
and not only basic.
Get started
git clone [dest_dir] Clone a reopsitory
git init Initializes a new repo
Where we are
git remote show will show all your remotes
git remote show origin show information for remote named origin
git remote add [name] [url] add a remote named [name] with url [url]
git remote rm [name] removes a remote named [name]
git status show git status
git status -sb summarized status
git branch show list of local branches
git branch --all show list of local and remote branches
git fetch fetch a remote origin/branch
git checkout [-b new_branch] checks out to a existing branch, or new branch if
-b is used
Commiting
git add add files to the commit
git add -p to add partial files
git add --all to add deleted files
git rm remove a tracked file
git rm --cached remove only the file track
git commit makes a commit
git commit -m "message" creates a commit with the spec. message
git commit -am "message" add all tracked files and commit with the message
git commit --ammend if you forgot to add something to the last commit
git reset
What is happening
git status
git log shows you the git log
git log --graph --abbrev-commit --decorate --
date=relative --format=format:'%C(bold
blue)%h%C(reset) - %C(bold green)(%ar)%C
(reset) %C(white)%s%C(reset) %C(dim white)
- %an%C(reset)%C(bold yellow)%d%C(reset)'
--all
Pretty log !
git diff
git whatchanged file
git blame file
Git pull, git push
git pull origin master pulls branch master from remote origin to local
branch master
git push bitbucket master:dev git pushes the local branch dev to remote
branch master at origin bitbucket
Git pull, git push
git pull origin master pulls branch master from remote origin to local
branch master
git push bitbucket master:dev git pushes the local branch dev to remote
branch master at origin bitbucket
Git stash (get ride of your local changes)
git stash stashes your local changes
git stash list show stashes
git stash apply | pop <stash> re - apply a stash
git stash drop <stash> deletes a stash
git stash branch <stash>
Read More at http://git-scm.com/docs/git-stash
Git merge
Others
● Rebase http://git-scm.com/book/en/Git-Branching-Rebasing
● Revert
● cherry-pick
Useful Tools & Resources
● TIG -> http://jonas.nitro.dk/tig/
● Meld -> http://meldmerge.org/
● SourceTree ->http://www.sourcetreeapp.com/
● Git Cola -> http://git-cola.github.io/
● GitX -> http://gitx.frim.nl/
● StupidGit -> https://github.com/gyim/stupidgit
● GitHowTo -> http://githowto.com/
● Tower CheatSheet
?>
End

More Related Content

What's hot

Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Webinar - Automated Puppet Code Deployment with R10K
Webinar - Automated Puppet Code Deployment with R10KWebinar - Automated Puppet Code Deployment with R10K
Webinar - Automated Puppet Code Deployment with R10KOlinData
 
SCMBC闇LT資料
SCMBC闇LT資料SCMBC闇LT資料
SCMBC闇LT資料bleis tift
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooDennis Rowe
 
CRONtab Tutorial
CRONtab TutorialCRONtab Tutorial
CRONtab TutorialJoseph ...
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Job Automation using Linux
Job Automation using LinuxJob Automation using Linux
Job Automation using LinuxJishnu Pradeep
 
Rails Plugins 2 Hoe
Rails Plugins 2 HoeRails Plugins 2 Hoe
Rails Plugins 2 Hoeoscon2007
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 
Hello git - a soft introduction to git (Talk Slides)
Hello git - a soft introduction to git (Talk Slides) Hello git - a soft introduction to git (Talk Slides)
Hello git - a soft introduction to git (Talk Slides) Amity University Noida
 
Git хуки на страже качества кода
Git хуки на страже качества кодаGit хуки на страже качества кода
Git хуки на страже качества кодаBadoo Development
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a gitBerny Cantos
 

What's hot (19)

Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Webinar - Automated Puppet Code Deployment with R10K
Webinar - Automated Puppet Code Deployment with R10KWebinar - Automated Puppet Code Deployment with R10K
Webinar - Automated Puppet Code Deployment with R10K
 
いつやるの?Git入門
いつやるの?Git入門いつやるの?Git入門
いつやるの?Git入門
 
Git cheat-sheet
Git cheat-sheetGit cheat-sheet
Git cheat-sheet
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
SCMBC闇LT資料
SCMBC闇LT資料SCMBC闇LT資料
SCMBC闇LT資料
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, too
 
Cron
CronCron
Cron
 
CRONtab Tutorial
CRONtab TutorialCRONtab Tutorial
CRONtab Tutorial
 
grep.metacpan.org
grep.metacpan.orggrep.metacpan.org
grep.metacpan.org
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Job Automation using Linux
Job Automation using LinuxJob Automation using Linux
Job Automation using Linux
 
Rails Plugins 2 Hoe
Rails Plugins 2 HoeRails Plugins 2 Hoe
Rails Plugins 2 Hoe
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Hello git - a soft introduction to git (Talk Slides)
Hello git - a soft introduction to git (Talk Slides) Hello git - a soft introduction to git (Talk Slides)
Hello git - a soft introduction to git (Talk Slides)
 
Git хуки на страже качества кода
Git хуки на страже качества кодаGit хуки на страже качества кода
Git хуки на страже качества кода
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Magie di git
Magie di gitMagie di git
Magie di git
 
Sacándole jugo a git
Sacándole jugo a gitSacándole jugo a git
Sacándole jugo a git
 

Viewers also liked

CONGRUENT TRIANGLES
CONGRUENT TRIANGLESCONGRUENT TRIANGLES
CONGRUENT TRIANGLESpgbhavan
 
11 Signs We're Writing Too Many List Posts
11 Signs We're Writing Too Many List Posts11 Signs We're Writing Too Many List Posts
11 Signs We're Writing Too Many List PostsWalt Now
 
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02IRFAN ALI KHAN
 
Final powerpoint
Final powerpointFinal powerpoint
Final powerpointCara Pleym
 
Rcm produts rate are changed
Rcm produts rate are changedRcm produts rate are changed
Rcm produts rate are changedRcm Mission
 
Gentile maurizio template summer 2010 [modalità compatibilità]
Gentile maurizio template summer 2010 [modalità compatibilità]Gentile maurizio template summer 2010 [modalità compatibilità]
Gentile maurizio template summer 2010 [modalità compatibilità]Univirtual
 
Drogas e internamiento judicial
Drogas e internamiento judicialDrogas e internamiento judicial
Drogas e internamiento judicialrsanjorge
 
Södertälje hamn, Hub forum 21 nov 2012
Södertälje hamn, Hub forum 21 nov 2012Södertälje hamn, Hub forum 21 nov 2012
Södertälje hamn, Hub forum 21 nov 2012Erik Froste
 
Orange subho
Orange subhoOrange subho
Orange subhocrycom
 
Revision 1 - Audience case study
Revision 1  - Audience case study Revision 1  - Audience case study
Revision 1 - Audience case study Elle Sullivan
 

Viewers also liked (17)

Argohost
ArgohostArgohost
Argohost
 
Tomas talianom
Tomas   talianomTomas   talianom
Tomas talianom
 
CONGRUENT TRIANGLES
CONGRUENT TRIANGLESCONGRUENT TRIANGLES
CONGRUENT TRIANGLES
 
Estudo de caso
Estudo de casoEstudo de caso
Estudo de caso
 
11 Signs We're Writing Too Many List Posts
11 Signs We're Writing Too Many List Posts11 Signs We're Writing Too Many List Posts
11 Signs We're Writing Too Many List Posts
 
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02
Unmannedrailwaytrackingandanti collisionsystemusinggsm-130621072905-phpapp02
 
Final powerpoint
Final powerpointFinal powerpoint
Final powerpoint
 
Dit yvol3iss4
Dit yvol3iss4Dit yvol3iss4
Dit yvol3iss4
 
Rcm produts rate are changed
Rcm produts rate are changedRcm produts rate are changed
Rcm produts rate are changed
 
Topic 5
Topic 5Topic 5
Topic 5
 
Gentile maurizio template summer 2010 [modalità compatibilità]
Gentile maurizio template summer 2010 [modalità compatibilità]Gentile maurizio template summer 2010 [modalità compatibilità]
Gentile maurizio template summer 2010 [modalità compatibilità]
 
Ctae
CtaeCtae
Ctae
 
Drogas e internamiento judicial
Drogas e internamiento judicialDrogas e internamiento judicial
Drogas e internamiento judicial
 
Chapter 8b
Chapter 8bChapter 8b
Chapter 8b
 
Södertälje hamn, Hub forum 21 nov 2012
Södertälje hamn, Hub forum 21 nov 2012Södertälje hamn, Hub forum 21 nov 2012
Södertälje hamn, Hub forum 21 nov 2012
 
Orange subho
Orange subhoOrange subho
Orange subho
 
Revision 1 - Audience case study
Revision 1  - Audience case study Revision 1  - Audience case study
Revision 1 - Audience case study
 

Similar to Git why how when and more

Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Mizan Riqzia
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Git with the flow
Git with the flowGit with the flow
Git with the flowDana White
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroductionBruno Bossola
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciAtlassian
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroductionCodemotion
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 

Similar to Git why how when and more (20)

GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git Primer
Git PrimerGit Primer
Git Primer
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
 
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git
GitGit
Git
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroduction
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
3 Git
3 Git3 Git
3 Git
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 

Git why how when and more

  • 1. Git . Why, How, and more @gargrag | correo@gaston.com.uy
  • 2. PM -> track working PM -> control the team PM -> interact with the process. PM -> know wich issues is the team working on. DEV -> co-work DEV -> rollback DEV -> manipulate changes DEV -> parallel versions SUP -> know what code is deployed SUP -> see which are the latest changes SUP -> pull request some easy issues Why Git ?
  • 3. ● remotes ● commits ● tags ● branches ● local / remote Basic explanation
  • 4. Good practices . keep calm and take control
  • 5. Commit often Git can control only the code you commit, so commit early and often, that's the way to have your code under control and backed up.
  • 6. Be reversible Make commits atomically, use all the git potencial, to make commits clear, by feature and reversible. Git has all you need to commit changes grouped by each, fix/feature you code.
  • 7. Make clear and useful commit msgs Besides making reversible, and atomic commits, ship they with descriptive messages, so other teammates can know exactly what each commit is about (especially under stress)
  • 8. Divide and conquer If your code goes too large, divide it in repos by modules or something depending on the software architecture you are on. You can use either submodules or separate repositories.
  • 9. Get updated Pull often, and before start working.
  • 10. Remember your workflow We have defined a workflow, remember it, and act accord.
  • 11. Be ware of changing public history Git allows you to change the published history, but it can be an annoyance for your teammates. Better, fix the things by doing commits, maybe by revert, or patching, etc. But going forward.
  • 12. Don't freak All your code is under control, any change is rollback- able, any non - recursive merge, can be done with ease. keep calm, things can look nasty, but belive me, is simple.
  • 13. Use a custom prompt Use a custom unix prompt, that shows you info about the repo you are working with, the branch you are, the status and more things. export PS1='[u@h W$(__git_ps1 " (%s)")]$ ' git has some ps1 variables and functions you can set up, and if you prefer something more sophisticated take a look at: ● https://github.com/nojhan/liquidprompt ● https://github.com/bpinto/oh-my-fish
  • 14. Maintain your repo Do some maintenance, sure someone has versioned a mysql dump, and your repo is growing insanely. Take care of that, and maintain the repo often. Repack, delete weight files, and put order.
  • 15. Rtfm! and take some practice. ● http://pcottle.github.io/learnGitBranching/ ● http://git-scm.com/book/ch3-4.html ● https://www.codeschool.com/courses/try-git ● https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+101
  • 16. Basic commands and not only basic.
  • 17. Get started git clone [dest_dir] Clone a reopsitory git init Initializes a new repo
  • 18. Where we are git remote show will show all your remotes git remote show origin show information for remote named origin git remote add [name] [url] add a remote named [name] with url [url] git remote rm [name] removes a remote named [name] git status show git status git status -sb summarized status git branch show list of local branches git branch --all show list of local and remote branches git fetch fetch a remote origin/branch git checkout [-b new_branch] checks out to a existing branch, or new branch if -b is used
  • 19. Commiting git add add files to the commit git add -p to add partial files git add --all to add deleted files git rm remove a tracked file git rm --cached remove only the file track git commit makes a commit git commit -m "message" creates a commit with the spec. message git commit -am "message" add all tracked files and commit with the message git commit --ammend if you forgot to add something to the last commit git reset
  • 20. What is happening git status git log shows you the git log git log --graph --abbrev-commit --decorate -- date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C (reset) %C(white)%s%C(reset) %C(dim white) - %an%C(reset)%C(bold yellow)%d%C(reset)' --all Pretty log ! git diff git whatchanged file git blame file
  • 21. Git pull, git push git pull origin master pulls branch master from remote origin to local branch master git push bitbucket master:dev git pushes the local branch dev to remote branch master at origin bitbucket
  • 22. Git pull, git push git pull origin master pulls branch master from remote origin to local branch master git push bitbucket master:dev git pushes the local branch dev to remote branch master at origin bitbucket
  • 23. Git stash (get ride of your local changes) git stash stashes your local changes git stash list show stashes git stash apply | pop <stash> re - apply a stash git stash drop <stash> deletes a stash git stash branch <stash> Read More at http://git-scm.com/docs/git-stash
  • 25. Others ● Rebase http://git-scm.com/book/en/Git-Branching-Rebasing ● Revert ● cherry-pick Useful Tools & Resources ● TIG -> http://jonas.nitro.dk/tig/ ● Meld -> http://meldmerge.org/ ● SourceTree ->http://www.sourcetreeapp.com/ ● Git Cola -> http://git-cola.github.io/ ● GitX -> http://gitx.frim.nl/ ● StupidGit -> https://github.com/gyim/stupidgit ● GitHowTo -> http://githowto.com/ ● Tower CheatSheet