SlideShare a Scribd company logo
Carlos Duarte Do Nascimento
@chesterbr • http://chester.me
git fail --force
make it up with your pull requests
Let’s write some code!
Whoops...
WTF?
It’s either “git for dummies”...
Hovertext:“If that doesn't fix it, git.txt
contains the phone number of a friend
of mine who understands git.
Just wait through a few minutes of 'It's
really pretty simple, just think of
branches as...' and eventually you'll learn
the commands that will fix everything.”
Git - 30/Out/2015
https://xkcd.com/1597/
Neither rookie nor expert
Good professionals will try to become
proficient in their tools - not become
specialists in all of them
Expert Advice
● “Do a git pull once in a while”
● “Never use git pull”
● “Always rebase!”
● “Never rebase!!!”
● ...
How does that end?
Proposal
Revisit git concepts from the
perspective of a typical workflow,
avoiding theory overload and the
abuse of rules and cookbooks
Carlos Duarte Do Nascimento
(Chester)
@chesterbr • http://chester.me
Git non-specialist
https://www.shopify.com/careers
Git
A system that allows people to work
with source code in an orderly and
simultaneous fashion
Commit
When a meaningful change is made,
you take it to the stage in order to
take a snapshot (commit)
A92347C2…1F2493E34: Increase submit button size
DescriptionID
Commit == snapshot
“Git is all about composing and saving
snapshots of your project and then
working with and comparing those
snapshots”
http://gitref.org/basic/
Branch
Successive commits form a timeline
One can commit into alternative
timelines (branches) and later integrate
those with the main timeline (master)
Group work
Your commits “live” in your local
repository (.git/)
You can push commits to other
people’s repositories (remotes), and
also pull commits from there
Organizing your group
This flow of commits/branches can be
organized in several ways (workflows)
A central repository that
enables code reviews by means
of pull requests helps a lot...
● Refresh master (remote ⇒ local)
● Create new branch from there
● Commits, commits, commits!
● Push, PR (my branch ⇒ master)
●
●
But what if...
● ...CI* fails?
● ...other devs suggest changes?
● ...master changed while I worked?
*Continuous Integration
Conflict!
Image © 1995 GAINAX/Project Eva.
Manual merge
$ git checkout master
$ git pull
$ git checkout my-branch
...
$ git commit
$ git push
...
$ git push --force
#NOT
It can get really bad
● Irreconcilable conflicts
● Alien commits on my PR
● Commit is there, code is not
● The @#%@ button is still grey
● ...
How can we fix/avoid that?
By understanding what is happening on
a pull request to identify (and avoid)
traps, or, as a last resource, to rebuild
our PR with minimal effort
Pull request
Pull Merge request
“wants to merge?”
git merge
Includes commits from another branch in
the current one, without changing them
(an extra commit at the end will
consolidate changes from both sides)
How can that go wrong?
Consolidating changes from two
different timelines becomes more
complex as they diverge
Avoid the problem
Whenever possible, create small,
isolated and short-living branches
If you can’t avoid it
There are several ways to make a
branch compatible with master again
Our workflow works well with rebase
git rebase
Rebuild the branch from its original
point (by default), creating new commits
identical to the original ones (by default)
(hint: these defaults won’t help you)
What can I do with rebase?
● (re-)base your changes on a more
recent master
(e.g.: git fetch; git rebase origin/master)
● Simplify your commits
(e.g.: git rebase --interactive master)
How can that go wrong?
Updating the branch and simplifying
commits at the same time is tricky
Rewriting a branch that is already
published causes incompatibilities
PR prep suggestion (1)
Recreate your branch from a
more recent master
(without changing the commits)
git checkout master
git pull
git checkout my-branch
git rebase master
PR prep suggestion (2)
Simplify your commits
(without changing the branch point)
git rebase –-interactive master
Suggestion ≠ rule
If the master didn’t change (much),
don’t botter updating
If your commits are clear,
don’t bother interacting
After the PR is created
New commits can be added to the
remote, just git push them
Rebase, however, isn’t that simple
(why?)
Rebases change the past!!!
(uhhh... so what?)
Image © Universal Studios.All rights Reserved
Is that a real problem?
A git push from a rebased branch has
to replace the remote branch history
(hence the --force requirement)
Workflow to the rescue
If the workflow says
only the creator
commits on a PR,
rebasing its branch
should not cause
any trouble
Image © 2016Twentieth Century Fox Film Corporation.
Avoiding further trouble
Just like before the first push, don’t
change the start point and
simplify commits at the same time
A new commit is always less
tricky than a rebase
Master is sacred
Branches / pull requests are only
relevant during their lifetime
It hit the fan - now what?
git cherry-pick
Reproduces in your branch the
changes from a single commit
(even a branch-less one)
git cherry-pick id
Cherry-pick good commits
Instead of recreating changes manually,
we can cherry-pick the original
commits into a fresh branch
But we need to find those commits...
git log x git reflog
git log lists commits created in the
current branch (lots of search options)
git reflog lists any operations that
affected the local repository in any way
git reflog
f84195a HEAD@{0}: checkout: moving from 1468-more-resilience-on-in
d5a8868 HEAD@{1}: commit: Log the invalid listing on offer-less of
79e7c98 HEAD@{2}: commit: Better test naming and more detailed log
31e2ac1 HEAD@{3}: checkout: moving from master to 1468-more-resili
f84195a HEAD@{4}: rebase finished: returning to refs/heads/master
f84195a HEAD@{5}: pull --rebase --autostash: checkout f84195a626e9
ac12705 HEAD@{6}: rebase finished: returning to refs/heads/master
ac12705 HEAD@{7}: pull --rebase --autostash: checkout ac127053051c
...
#howto
1. Find all the commits that were
supposed to be on your PR
git log • git reflog •
#howto
2. Sync your master with the server
and create a brand new branch from it
git checkout master
git pull
git checkout -b new-branch
#howto
3.Apply the commits
git cherry-pick id1 id2 id3...
#howto
4. Replace the old branch with the new
one (on local and remote repos)
git checkout master
git branch -D my-branch
git branch -m new-branch my-branch
git checkout my-branch
git push –-set-upstream origin my-branch
--force
Life is good again!
Conclusion (1)
You don’t need to know everything
about git, but it’s a good idea to have a
solid understanding of some concepts
(e.g.: commit, branch, merge, rebase)
Conclusion (2)
As long as it was committed, there is
always a way to recover your work.
Avoiding push accidents
Image © CAPCOM Ltd..All rights Reserved
Don’t use the --force, Luke
Make a habit of trying “vanilla” git
push before adding any arguments
(e.g., origin my-branch or --force)
On a new branch
$ git checkout -b new-branch
Switched to a new branch 'new-branch'
$ git commit -am "my changes"
[new-branch eabe2c9] my changes
1 file changed, 2 insertions(+)
$ git push
fatal: The current branch new-branch has no upstream branch
To push the current branch and set the remote as upstream,
use
git push --set-upstream origin new-branch
$ git push --set-upstream origin new-branch
After a rebase
$ git rebase -i master
Switched to a new branch 'new-branch'
$ git push
To github.com:Shopify/some-repo.git
! [rejected] new-branch -> new-branch (non-fast-forward)
error: failed to push some refs to 'github.com:Shopify/
some-repo.git'
hint: Updates were rejected because the tip of your current
branch is behind
$ git push --force
Know where you are
Always show the current branch on
your command line prompt (bash):
export PS1="h:W u[033[32m]
$(__git_ps1)[033[00m]$ "
MyComputer:myproject me (my-branch)$
GUI x CLI
Image CC BY-SAWikipedia user Sandstein
gitk
GitHub Desktop
Tig
Stay fresh
Update your master to the latest
remote without leaving your branch
git pull --rebase --autostash
For git < 2.9, use the git-up gem
gem install git-up
git up
Non-brute force
Rewrite history, but only if no one else
added commits to the branch
git push --force-with-lease
Branch prefix shortcuts
git push --delete my-branch
git push --force my-branch
can be shortened to
git push :my-branch
git push +my-branch
(just be careful not to add + by habit)
Thank you!
Carlos Duarte Do Nascimento
@chesterbr • http://chester.me
shopify.com/careers
http://slideshare.net/chesterbr
This presentation is available under the Creative Commons “by-nc” 3.0 license
(available at https://creativecommons.org/licenses/by-nc/3.0/),
noticing the exceptions below.
Images and text from third parties were included (with due credits wherever possible)
under a fair use assumption (or, for Brazilian media, under Art. 46 of Law 9610/98)
and/or under their respective licenses. Omissions are unintended and corrections
welcome. Such content is excluded from the license above.
GitHub, the GitHub logo and mascot are trademarks of GitHub, Inc.
Shopify and the Shopify logo are trademaks of Shopify, Inc.
The opinions stated here belong solely to the author, not offically representing his
employer’s opinions, nor any of of the persons or companies mentioned in any extent.
Credits And License

More Related Content

What's hot

Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
Chia Wei Tsai
 
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Git flow
Git flowGit flow
Git flow
Suraj Aair
 
Github
GithubGithub
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
Alberto Leal
 
Git workflows
Git workflowsGit workflows
Git workflows
Sergiu Savva
 
How to use any static site generator with GitLab Pages.
How to use any static site generator with GitLab Pages. How to use any static site generator with GitLab Pages.
How to use any static site generator with GitLab Pages.
Ivan Nemytchenko
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
David Paluy
 
My Git workflow
My Git workflowMy Git workflow
My Git workflow
Rui Carvalho
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android Developer
Effective
 
Git Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential CommandsGit Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential Commands
Jeremy Lindblom
 
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
The Linux Foundation
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile development
Zack Siri
 
GitHub Talk - Cody Carnachan
GitHub Talk - Cody CarnachanGitHub Talk - Cody Carnachan
GitHub Talk - Cody Carnachan
Cody Carnachan
 
Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?
John Congdon
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Git Flow - An Introduction
Git Flow - An IntroductionGit Flow - An Introduction
Git Flow - An Introduction
Knoldus Inc.
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
Bo-Yi Wu
 

What's hot (20)

Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
 
Git advanced
Git advancedGit advanced
Git advanced
 
Git flow
Git flowGit flow
Git flow
 
Github
GithubGithub
Github
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git workflows
Git workflowsGit workflows
Git workflows
 
How to use any static site generator with GitLab Pages.
How to use any static site generator with GitLab Pages. How to use any static site generator with GitLab Pages.
How to use any static site generator with GitLab Pages.
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
My Git workflow
My Git workflowMy Git workflow
My Git workflow
 
Git For The Android Developer
Git For The Android DeveloperGit For The Android Developer
Git For The Android Developer
 
Git Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential CommandsGit Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential Commands
 
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile development
 
GitHub Talk - Cody Carnachan
GitHub Talk - Cody CarnachanGitHub Talk - Cody Carnachan
GitHub Talk - Cody Carnachan
 
Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Git Flow - An Introduction
Git Flow - An IntroductionGit Flow - An Introduction
Git Flow - An Introduction
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
 

Similar to git fail --force (make it up with your pull requests)

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
Susan Tan
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
Shinho Kang
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
Stephen Yeargin
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
Katie Sylor-Miller
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
Hasnaeen Rahman
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
Gerrit Wanderer
 
Git tips
Git tipsGit tips
Git tips
Arthur Shvetsov
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
James Ford
 
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
Christoph Matthies
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
Kanstantsin Shautsou
 
Git
GitGit
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
Johan Abildskov
 
Managing releases effectively through git
Managing releases effectively through gitManaging releases effectively through git
Managing releases effectively through git
Mohd Farid
 

Similar to git fail --force (make it up with your pull requests) (20)

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Honestly Git Playground 20190221
Honestly Git Playground 20190221Honestly Git Playground 20190221
Honestly Git Playground 20190221
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Git tips
Git tipsGit tips
Git tips
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git github
Git githubGit github
Git github
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
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
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
 
Git
GitGit
Git
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
 
Managing releases effectively through git
Managing releases effectively through gitManaging releases effectively through git
Managing releases effectively through git
 

More from Carlos Duarte do Nascimento

git fail --force (faça as pazes com seus pull requests)
git fail --force (faça as pazes com seus pull requests)git fail --force (faça as pazes com seus pull requests)
git fail --force (faça as pazes com seus pull requests)
Carlos Duarte do Nascimento
 
ruby2600 - an Atari 2600 emulator written in Ruby
ruby2600 - an Atari 2600 emulator written in Rubyruby2600 - an Atari 2600 emulator written in Ruby
ruby2600 - an Atari 2600 emulator written in Ruby
Carlos Duarte do Nascimento
 
Atari 2600 VCS Programming
Atari 2600 VCS ProgrammingAtari 2600 VCS Programming
Atari 2600 VCS Programming
Carlos Duarte do Nascimento
 
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
Carlos Duarte do Nascimento
 
Programação para Atari 2600
Programação para Atari 2600Programação para Atari 2600
Programação para Atari 2600
Carlos Duarte do Nascimento
 
Mashups: Criando Valor na Web 2.0 (BandTec)
Mashups: Criando Valor na Web 2.0 (BandTec)Mashups: Criando Valor na Web 2.0 (BandTec)
Mashups: Criando Valor na Web 2.0 (BandTec)
Carlos Duarte do Nascimento
 
Aplicativos Mobile: Da Idéia ao Produto (ou não)
Aplicativos Mobile: Da Idéia ao Produto (ou não)Aplicativos Mobile: Da Idéia ao Produto (ou não)
Aplicativos Mobile: Da Idéia ao Produto (ou não)
Carlos Duarte do Nascimento
 
Apontador API (para programadores Python)
Apontador API (para programadores Python)Apontador API (para programadores Python)
Apontador API (para programadores Python)
Carlos Duarte do Nascimento
 
Mashups: Criando Valor na Web 2.0
Mashups: Criando Valor na Web 2.0Mashups: Criando Valor na Web 2.0
Mashups: Criando Valor na Web 2.0
Carlos Duarte do Nascimento
 
Cruzalinhas - Palestra Relâmpago no Fisl 11
Cruzalinhas - Palestra Relâmpago no Fisl 11Cruzalinhas - Palestra Relâmpago no Fisl 11
Cruzalinhas - Palestra Relâmpago no Fisl 11
Carlos Duarte do Nascimento
 
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
Carlos Duarte do Nascimento
 

More from Carlos Duarte do Nascimento (11)

git fail --force (faça as pazes com seus pull requests)
git fail --force (faça as pazes com seus pull requests)git fail --force (faça as pazes com seus pull requests)
git fail --force (faça as pazes com seus pull requests)
 
ruby2600 - an Atari 2600 emulator written in Ruby
ruby2600 - an Atari 2600 emulator written in Rubyruby2600 - an Atari 2600 emulator written in Ruby
ruby2600 - an Atari 2600 emulator written in Ruby
 
Atari 2600 VCS Programming
Atari 2600 VCS ProgrammingAtari 2600 VCS Programming
Atari 2600 VCS Programming
 
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
Desenvolvimento de Aplicações para o Google App Engine (CPBR5)
 
Programação para Atari 2600
Programação para Atari 2600Programação para Atari 2600
Programação para Atari 2600
 
Mashups: Criando Valor na Web 2.0 (BandTec)
Mashups: Criando Valor na Web 2.0 (BandTec)Mashups: Criando Valor na Web 2.0 (BandTec)
Mashups: Criando Valor na Web 2.0 (BandTec)
 
Aplicativos Mobile: Da Idéia ao Produto (ou não)
Aplicativos Mobile: Da Idéia ao Produto (ou não)Aplicativos Mobile: Da Idéia ao Produto (ou não)
Aplicativos Mobile: Da Idéia ao Produto (ou não)
 
Apontador API (para programadores Python)
Apontador API (para programadores Python)Apontador API (para programadores Python)
Apontador API (para programadores Python)
 
Mashups: Criando Valor na Web 2.0
Mashups: Criando Valor na Web 2.0Mashups: Criando Valor na Web 2.0
Mashups: Criando Valor na Web 2.0
 
Cruzalinhas - Palestra Relâmpago no Fisl 11
Cruzalinhas - Palestra Relâmpago no Fisl 11Cruzalinhas - Palestra Relâmpago no Fisl 11
Cruzalinhas - Palestra Relâmpago no Fisl 11
 
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
SlideMeme - Habilitando o SlideShare dentro do Yahoo! Meme - Yahoo! Open Hack...
 

Recently uploaded

Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
OnePlan Solutions
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
narinav14
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 

Recently uploaded (20)

Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 

git fail --force (make it up with your pull requests)

  • 1. Carlos Duarte Do Nascimento @chesterbr • http://chester.me git fail --force make it up with your pull requests
  • 5.
  • 6.
  • 7. It’s either “git for dummies”...
  • 8.
  • 9.
  • 10. Hovertext:“If that doesn't fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of 'It's really pretty simple, just think of branches as...' and eventually you'll learn the commands that will fix everything.” Git - 30/Out/2015 https://xkcd.com/1597/
  • 11. Neither rookie nor expert Good professionals will try to become proficient in their tools - not become specialists in all of them
  • 12. Expert Advice ● “Do a git pull once in a while” ● “Never use git pull” ● “Always rebase!” ● “Never rebase!!!” ● ...
  • 14. Proposal Revisit git concepts from the perspective of a typical workflow, avoiding theory overload and the abuse of rules and cookbooks
  • 15. Carlos Duarte Do Nascimento (Chester) @chesterbr • http://chester.me Git non-specialist
  • 17.
  • 18. Git A system that allows people to work with source code in an orderly and simultaneous fashion
  • 19. Commit When a meaningful change is made, you take it to the stage in order to take a snapshot (commit) A92347C2…1F2493E34: Increase submit button size DescriptionID
  • 20. Commit == snapshot “Git is all about composing and saving snapshots of your project and then working with and comparing those snapshots” http://gitref.org/basic/
  • 21. Branch Successive commits form a timeline One can commit into alternative timelines (branches) and later integrate those with the main timeline (master)
  • 22. Group work Your commits “live” in your local repository (.git/) You can push commits to other people’s repositories (remotes), and also pull commits from there
  • 23. Organizing your group This flow of commits/branches can be organized in several ways (workflows) A central repository that enables code reviews by means of pull requests helps a lot...
  • 24. ● Refresh master (remote ⇒ local) ● Create new branch from there ● Commits, commits, commits! ● Push, PR (my branch ⇒ master) ● ●
  • 25. But what if... ● ...CI* fails? ● ...other devs suggest changes? ● ...master changed while I worked? *Continuous Integration
  • 26. Conflict! Image © 1995 GAINAX/Project Eva.
  • 27. Manual merge $ git checkout master $ git pull $ git checkout my-branch ... $ git commit $ git push ... $ git push --force
  • 28. #NOT
  • 29. It can get really bad ● Irreconcilable conflicts ● Alien commits on my PR ● Commit is there, code is not ● The @#%@ button is still grey ● ...
  • 30. How can we fix/avoid that? By understanding what is happening on a pull request to identify (and avoid) traps, or, as a last resource, to rebuild our PR with minimal effort
  • 33. git merge Includes commits from another branch in the current one, without changing them (an extra commit at the end will consolidate changes from both sides)
  • 34. How can that go wrong? Consolidating changes from two different timelines becomes more complex as they diverge
  • 35. Avoid the problem Whenever possible, create small, isolated and short-living branches
  • 36. If you can’t avoid it There are several ways to make a branch compatible with master again Our workflow works well with rebase
  • 37. git rebase Rebuild the branch from its original point (by default), creating new commits identical to the original ones (by default) (hint: these defaults won’t help you)
  • 38. What can I do with rebase? ● (re-)base your changes on a more recent master (e.g.: git fetch; git rebase origin/master) ● Simplify your commits (e.g.: git rebase --interactive master)
  • 39. How can that go wrong? Updating the branch and simplifying commits at the same time is tricky Rewriting a branch that is already published causes incompatibilities
  • 40. PR prep suggestion (1) Recreate your branch from a more recent master (without changing the commits) git checkout master git pull git checkout my-branch git rebase master
  • 41. PR prep suggestion (2) Simplify your commits (without changing the branch point) git rebase –-interactive master
  • 42. Suggestion ≠ rule If the master didn’t change (much), don’t botter updating If your commits are clear, don’t bother interacting
  • 43. After the PR is created New commits can be added to the remote, just git push them Rebase, however, isn’t that simple (why?)
  • 44. Rebases change the past!!! (uhhh... so what?) Image © Universal Studios.All rights Reserved
  • 45. Is that a real problem? A git push from a rebased branch has to replace the remote branch history (hence the --force requirement)
  • 46. Workflow to the rescue If the workflow says only the creator commits on a PR, rebasing its branch should not cause any trouble Image © 2016Twentieth Century Fox Film Corporation.
  • 47. Avoiding further trouble Just like before the first push, don’t change the start point and simplify commits at the same time A new commit is always less tricky than a rebase
  • 48. Master is sacred Branches / pull requests are only relevant during their lifetime
  • 49. It hit the fan - now what?
  • 50. git cherry-pick Reproduces in your branch the changes from a single commit (even a branch-less one) git cherry-pick id
  • 51. Cherry-pick good commits Instead of recreating changes manually, we can cherry-pick the original commits into a fresh branch But we need to find those commits...
  • 52. git log x git reflog git log lists commits created in the current branch (lots of search options) git reflog lists any operations that affected the local repository in any way
  • 53. git reflog f84195a HEAD@{0}: checkout: moving from 1468-more-resilience-on-in d5a8868 HEAD@{1}: commit: Log the invalid listing on offer-less of 79e7c98 HEAD@{2}: commit: Better test naming and more detailed log 31e2ac1 HEAD@{3}: checkout: moving from master to 1468-more-resili f84195a HEAD@{4}: rebase finished: returning to refs/heads/master f84195a HEAD@{5}: pull --rebase --autostash: checkout f84195a626e9 ac12705 HEAD@{6}: rebase finished: returning to refs/heads/master ac12705 HEAD@{7}: pull --rebase --autostash: checkout ac127053051c ...
  • 54. #howto 1. Find all the commits that were supposed to be on your PR git log • git reflog •
  • 55. #howto 2. Sync your master with the server and create a brand new branch from it git checkout master git pull git checkout -b new-branch
  • 56. #howto 3.Apply the commits git cherry-pick id1 id2 id3...
  • 57. #howto 4. Replace the old branch with the new one (on local and remote repos) git checkout master git branch -D my-branch git branch -m new-branch my-branch git checkout my-branch git push –-set-upstream origin my-branch --force
  • 58. Life is good again!
  • 59. Conclusion (1) You don’t need to know everything about git, but it’s a good idea to have a solid understanding of some concepts (e.g.: commit, branch, merge, rebase)
  • 60. Conclusion (2) As long as it was committed, there is always a way to recover your work.
  • 61. Avoiding push accidents Image © CAPCOM Ltd..All rights Reserved
  • 62. Don’t use the --force, Luke Make a habit of trying “vanilla” git push before adding any arguments (e.g., origin my-branch or --force)
  • 63. On a new branch $ git checkout -b new-branch Switched to a new branch 'new-branch' $ git commit -am "my changes" [new-branch eabe2c9] my changes 1 file changed, 2 insertions(+) $ git push fatal: The current branch new-branch has no upstream branch To push the current branch and set the remote as upstream, use git push --set-upstream origin new-branch $ git push --set-upstream origin new-branch
  • 64. After a rebase $ git rebase -i master Switched to a new branch 'new-branch' $ git push To github.com:Shopify/some-repo.git ! [rejected] new-branch -> new-branch (non-fast-forward) error: failed to push some refs to 'github.com:Shopify/ some-repo.git' hint: Updates were rejected because the tip of your current branch is behind $ git push --force
  • 65. Know where you are Always show the current branch on your command line prompt (bash): export PS1="h:W u[033[32m] $(__git_ps1)[033[00m]$ " MyComputer:myproject me (my-branch)$
  • 66. GUI x CLI Image CC BY-SAWikipedia user Sandstein
  • 67. gitk
  • 69. Tig
  • 70.
  • 71. Stay fresh Update your master to the latest remote without leaving your branch git pull --rebase --autostash For git < 2.9, use the git-up gem gem install git-up git up
  • 72. Non-brute force Rewrite history, but only if no one else added commits to the branch git push --force-with-lease
  • 73. Branch prefix shortcuts git push --delete my-branch git push --force my-branch can be shortened to git push :my-branch git push +my-branch (just be careful not to add + by habit)
  • 74. Thank you! Carlos Duarte Do Nascimento @chesterbr • http://chester.me shopify.com/careers http://slideshare.net/chesterbr
  • 75. This presentation is available under the Creative Commons “by-nc” 3.0 license (available at https://creativecommons.org/licenses/by-nc/3.0/), noticing the exceptions below. Images and text from third parties were included (with due credits wherever possible) under a fair use assumption (or, for Brazilian media, under Art. 46 of Law 9610/98) and/or under their respective licenses. Omissions are unintended and corrections welcome. Such content is excluded from the license above. GitHub, the GitHub logo and mascot are trademarks of GitHub, Inc. Shopify and the Shopify logo are trademaks of Shopify, Inc. The opinions stated here belong solely to the author, not offically representing his employer’s opinions, nor any of of the persons or companies mentioned in any extent. Credits And License