SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
How Not To GIT
Lucas Gomes <@x8lucas8x>
Agenda
● Who am I?
● GIT Anti-Patterns
○ Manual Merging
○ Copy-Paste Backup
○ Dumb Bug Hunting
○ Dumb Conflict
Resolution
○ Jumbo Commit
2
○ Messing with History
○ Divergent Master
○ Self Reviewing
● References
● Q & A
Software Engineer
Passionate Hacker
ArchLinux Zealot
FOSS Enthusiast
I’m fond of doing
things that last
and all that jazz.
Lucas Lira Gomes
3
contact@x8lucas8x.com
linkedin.com/in/x8lucas8x
facebook.com/x8lucas8x
youtube.com/X80lucas08X
twitter.com/x8lucas8x
x8lucas8x.com
github.com/x8lucas8x
GIT Anti-Patterns
4
Manual Merging
5
$ git checkout branchA
...
$ git commit
...
$ git pull origin master
...
$ echo ‘No pull requests this time!’
...
$ git checkout master
...
$ git rebase branchA
...
$ git push origin master
...
Manual Merging
6
● Problems
○ “To Err is Human”
■ Automate what you can
○ Permission management
■ Higher friction
○ Jeopardise collaboration
■ Less code-review
Manual Merging
7
A’s
Local
B’s
Local
C’s
Local
Central
Remote
Shared
Repository
Manual Merging
8
A’s
Local
B’s
Local
Central
Remote
A’s
Remote
B’s
Remote
Fork
Pull
Manual Merging
9
● Solution
○ Fork & Pull model
■ Use proper tools
○ Avoid manual
merges/rebases
■ Default to pull
requests
Manual Merging
10
● Solution
○ Fork to access
■ Create it first
$ git clone git@server_url:my_fork/remote.git
Manual Merging
11
● Solution
○ For updates
■ Forbid pushes
■ Setup read-only
remote
$ git remote add central https://server_url/central/remote.git
$ git remote set-url central --push "You shall NOT push!!!"
Copy-Paste Backup
12
$ git status
# On branch master
# ...
# modified: index.html
#
...
$ cp index.html backup_index.html
...
$ git checkout -- index.html
...
$ git checkout branchB
Switched to a new branch 'branchB'
Copy-Paste Backup
13
● Problems
○ “To Err is Human”
■ Use proper tools
Copy-Paste Backup
14
● Solution
○ Stash it
$ git stash
Saved working directory and index state "WIP on master: 049d078 added the index file"
HEAD is now at 049d078 added the index file (To restore them type "git stash apply")
Copy-Paste Backup
15
● Solution
○ Stash it
$ git status
# On branch master
nothing to commit, working directory clean
$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
Copy-Paste Backup
16
● Solution
○ Stash it
$ git stash apply
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#
# modified: index.html
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
Dumb Bug Hunting
17
$ git commit
...
$ git commit
...
$ git commit
...
$ run app.py
FATAL ERROR
Gonna cry?
...
$ diff HEAD~12
...
$ vim app.py
...
Dumb Bug Hunting
18
● Problems
○ Not efficient
○ The more code
==
The harder
Dumb Bug Hunting
19
● Solution
○ Manual Bitsec
$ git bisect start
$ git bisect bad BAD_SHA1_HASH
$ git bisect good GOOD_SHA1_HASH
Bisecting: 6 revisions left to test after this
[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing
Dumb Bug Hunting
20
● Solution
○ Manual Bitsec
$ git bisect good
Bisecting: 3 revisions left to test after this
[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing
$ git bisect bad
Bisecting: 1 revisions left to test after this
[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table
Dumb Bug Hunting
21
● Solution
○ Manual Bitsec
$ git bisect good
b047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commit
commit b047b02ea83310a70fd603dc8cd7a6cd13d15c04
Author: User1 <user1@example.com>
Date: Tue Jan 27 14:48:32 2015 -0800
...
Dumb Bug Hunting
22
● Solution
○ Automate Bitsec
$ git bisect start BAD_SHA1_HASH GOOD_SHA1_HASH
$ git bisect run make test arguments
...
Dumb Conflict Resolution
23
$ git pull origin master
...
$ git status
# On branch branchA
# You have unmerged paths.
# ...
# both modified: README.md
#
...
$ vim README.md
...
Dumb Conflict Resolution
24
● Problems
○ Not efficient
○ Prone to typing errors
Dumb Conflict Resolution
25
● Solution
○ Use a mergetool
$ git config --global merge.tool YOUR_DIFF_VIEWER
Dumb Conflict Resolution
26
● Solution
○ Use a mergetool
$ git mergetool
Merging the files: README
Normal merge conflict for 'README':
{local}: modified
{remote}: modified
Hit return to start merge resolution tool (kdiff3):
Dumb Conflict Resolution
27
● Solution
○ Use a mergetool (KDiff3)
Dumb Conflict Resolution
28
● Solution
○ Use a mergetool (Meld)
Dumb Conflict Resolution
29
● Solution
○ Use a mergetool
■ emerge
■ gvimdiff
■ vimdiff
■ Your IDE’s differ
Jumbo Commit
30
$ git add src/views/.
...
$ git add src/models/.
...
$ git add src/delegates/.
...
$ git add images/.
...
$ git commit -a ‘Biggest commit ever!’
...
Jumbo Commit
31
● Problems
○ Long-term results
■ Team
○ Review procrastination
■ Higher cognitive load
○ Pulls are more prone to
conflict
Jumbo Commit
32
● Solution
○ Divide and conquer
■ Create granular
commits
Messing with History
33
$ git pull origin master
...
$ git log
...
$ git commit --amend
...
$ git push origin master
...
# ! [rejected] master -> master
(non-fast-forward)
...
Messing with History
34
● Problems
○ Cannot push
○ If forced (push -f)
■ Breaks others’
history
■ Lose commits
Messing with History
35
● Solution
○ Avoid messing with
pushed history
■ On shared
repositories only
Messing with History
36
● Solution
○ Use Git Revert
$ git revert DESIRED_SHA1_HASH
Divergent Master
37
$ git checkout master
...
$ git rebase branchA
...
$ git status
...
# Your branch and 'origin/master'
have diverged
...
Divergent Master
38
● Problems
○ Prone to mixing commits
of different branches
■ Master is the
ramification point
Divergent Master
39
● Solution
○ Use master as a carbon copy
$ git checkout -b branchA
Switched to a new branch 'branchA'
$ git branch -D master
...
Divergent Master
40
● Solution
○ Use master as a carbon copy
$ git branch -a
branchA
remotes/central/master
$ git checkout remotes/central/master
...
Divergent Master
41
● Solution
○ Use master as a carbon copy
$ git checkout -b master
Switched to a new branch ‘master’
Self Reviewing
42
$ git push origin branchA
...
$ echo “Lets create a pull request!”
...
Self Reviewing
43
● Problems
○ Team specialisation
■ “Not my code"
○ Less opportunity
■ Learning
■ Training
Self Reviewing
44
● Solution
○ Assign pull requests
to others
References
1. https://www.git-scm.com/
2. http://www.atlassian.com/git/tutorials/
45
How Not To GIT
Lucas Gomes <@x8lucas8x>

Más contenido relacionado

Similar a How Not To GIT

Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Enjoy fighting regressions_with_git_bisect
Enjoy fighting regressions_with_git_bisectEnjoy fighting regressions_with_git_bisect
Enjoy fighting regressions_with_git_bisectChristian Couder
 
Introduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control systemIntroduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control systemAlbanLevy
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git for Writers: Dumping the Bucket Metaphor
Git for Writers: Dumping the Bucket MetaphorGit for Writers: Dumping the Bucket Metaphor
Git for Writers: Dumping the Bucket MetaphorMysti Berry
 
Version control, you git
Version control, you gitVersion control, you git
Version control, you gitMayur Patil
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffective
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using GitTony Hillerson
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffectiveUI
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAdam Culp
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day workAlena Radkevich
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 

Similar a How Not To GIT (20)

Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Enjoy fighting regressions_with_git_bisect
Enjoy fighting regressions_with_git_bisectEnjoy fighting regressions_with_git_bisect
Enjoy fighting regressions_with_git_bisect
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Introduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control systemIntroduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control system
 
Git of every day
Git of every dayGit of every day
Git of every day
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git for Writers: Dumping the Bucket Metaphor
Git for Writers: Dumping the Bucket MetaphorGit for Writers: Dumping the Bucket Metaphor
Git for Writers: Dumping the Bucket Metaphor
 
Version control, you git
Version control, you gitVersion control, you git
Version control, you git
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using Git
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
 
How to git easily in day to-day work
How to git easily in day to-day workHow to git easily in day to-day work
How to git easily in day to-day work
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Github
GithubGithub
Github
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 

Más de Lucas Lira Gomes

Más de Lucas Lira Gomes (7)

Jest
JestJest
Jest
 
Context API in React
Context API in ReactContext API in React
Context API in React
 
Mobx
MobxMobx
Mobx
 
Search in Django
Search in DjangoSearch in Django
Search in Django
 
Kanban
KanbanKanban
Kanban
 
How To Open Source
How To Open SourceHow To Open Source
How To Open Source
 
Experiências de contribuição com o KDE/Amarok
Experiências de contribuição com o KDE/AmarokExperiências de contribuição com o KDE/Amarok
Experiências de contribuição com o KDE/Amarok
 

Último

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

How Not To GIT