SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
- My name Shawn Sorichetti
- going to talk about handling
coding mistakes with git
FIXUP
AND
AUTOSQUASH
Shawn Sorichetti
shawn@sorichetti.org
https://ssoriche.com
- I like to start git repositories with an
empty commit, as it creates a rebase
point at the beginning of the repository
- because yes, you can make a mistake
in the initial commit
- creating a develop branch to follow
process
- and now a feature branch
A LITTLE ENVIRONMENT SETUP
git init .
git commit -m "Initial commit" --allow-empty
git checkout -b develop
git checkout -b getting_started
Fixup and Autosquash // Shawn Sorichetti
- some super simple code just
to get the commits going
- this is far from real world, but
needed something to show
- Is that a good commit
message? No.
CREATE SOME SIMPLE CODE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
print "nHi namen";
git add my_name.pl
git commit -m "Initial code commit"
Fixup and Autosquash // Shawn Sorichetti
- some super simple code just
to get the commits going
- this is far from real world, but
needed something to show
- Is that a good commit
message? No.
CREATE SOME SIMPLE CODE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
print "nHi namen";
git add my_name.pl
git commit -m "Initial code commit"
Fixup and Autosquash // Shawn Sorichetti
- Going to introduce a change
to the code
CREATE A CHANGE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi namen";
git add -u
git commit -m "Add newline removal"
Fixup and Autosquash // Shawn Sorichetti
- this changes the way the
code works, and deserves a
separate change
CREATE A CHANGE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi namen";
git add -u
git commit -m "Add newline removal"
Fixup and Autosquash // Shawn Sorichetti
- when I created the initial code
I made a mistake, did you catch
it?
- failed to identify name as a
variable so name is printed
rather than the $name contents
INITIAL MISTAKE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi namen";
Fixup and Autosquash // Shawn Sorichetti
INITIAL MISTAKE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi $namen";
Fixup and Autosquash // Shawn Sorichetti
INITIAL MISTAKE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi $namen";
git add -u
Fixup and Autosquash // Shawn Sorichetti
- As this was a mistake and
doesn't change the story, it
should not be a separate commit
- just fix the existing commit
- the change has been staged
- but how do we deal with this
mistake
THEN WHAT DO YOU DO?
Fixup and Autosquash // Shawn Sorichetti
- create a new commit with a
distinctive subject reminding
me of what I need to do
- yeah... I forgot.
WHAT I USED TO DO
git commit -m "XXX Rebase and fix up into Initial commit"
Fixup and Autosquash // Shawn Sorichetti
AND THEN THIS HAPPENS
git checkout develop
git merge getting_started
git push origin develop
git log origin/develop --oneline
02cde46 (HEAD -> develop) XXX Rebase and fix up into Initial commit
46c49cf Add newline removal
9a0cb79 Initial code commit
cf186bb (master, develop) Initial commit
Fixup and Autosquash // Shawn Sorichetti
AND THEN THIS HAPPENS
git checkout develop
git merge getting_started
git push origin develop
git log origin/develop --oneline
02cde46 (HEAD -> develop) XXX Rebase and fix up into Initial commit
46c49cf Add newline removal
9a0cb79 Initial code commit
cf186bb (master, develop) Initial commit
Fixup and Autosquash // Shawn Sorichetti
FACEPALM
@mattmight
Fixup and Autosquash // Shawn Sorichetti
- creates a special kind of commit
that includes the subject of the
commit to be fixed
- now this isn't really what I
normally do, I use git log to
find the commit and capture the
SHA and just use that
WHAT I SHOULD HAVE DONE
git commit --fixup :/Initial
Fixup and Autosquash // Shawn Sorichetti
- which is a regex
- this for instance results in the latest commit with the
message matching Initial
- This power by the way is brought to you by rev-parse
- the --fixup argument accepts anything that git rev-
parse will allow
- highly recommend having a read through there
- it's amazing what all can be done to specify a
commit
- one of which is the latest commit of the file, but
that's another talk...
WHAT I SHOULD HAVE DONE
git commit --fixup :/Initial
git help rev-parse
Fixup and Autosquash // Shawn Sorichetti
NOW MY COMMITS LOOK LIKE THIS
git log --oneline
009b808 (HEAD -> getting_started) fixup! Initial code commit
46c49cf Add newline removal
9a0cb79 Initial code commit
cf186bb (master, develop) Initial commit
Fixup and Autosquash // Shawn Sorichetti
- wait a minute, before you had
XXX now you have fixup!
- this doesn't look better
HOW IS THAT BETTER?
Fixup and Autosquash // Shawn Sorichetti
AUTOSQUASH
Fixup and Autosquash // Shawn Sorichetti
- notice that git rebase moved the fixup
commit into
location and applies the fixup option
automatically
- now this is a simple example where there's
only 3 commits
- but imagine 20 - 40 commits, and trying to
move them around
- by hand
AUTOSQUASH
git rebase -i develop --autosquash
pick 9a0cb79 Initial code commit
fixup 2e72bb0 fixup! Initial code commit
pick 46c49cf Add newline removal
# Rebase cf186bb..2e72bb0 onto cf186bb (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
Fixup and Autosquash // Shawn Sorichetti
- Because this code is so
small, it does generate a
merge conflict
- which is pretty easy to fix
- just mentioning it for
completeness
MERGE CONFLICT
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
<<<<<<< HEAD
print "nHi namen";
=======
chomp($name);
print "nHi $namen";
>>>>>>> 2e72bb0... fixup! Initial code commit
Fixup and Autosquash // Shawn Sorichetti
GREAT FOR CODE REVIEWS
Fixup and Autosquash // Shawn Sorichetti
- this is a valid concern
FEEDBACK PROVIDED
Fixup and Autosquash // Shawn Sorichetti
- This is a simple fix
- if condition not to print if
there is no value
- yes, this doesn't handle if a
persons name is 0 or false
FIX IT IN THE CODE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi $namen" if $name;
git add -u
git commit --fixup :/Initial
git push origin getting_started
Fixup and Autosquash // Shawn Sorichetti
- stage the change for commit
- commit the change again
back to the initial commit
- the history of the request is
kept in the merge request, a
separate commit isn't required
FIX IT IN THE CODE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi $namen" if $name;
git add -u
git commit --fixup :/Initial
git push origin getting_started
Fixup and Autosquash // Shawn Sorichetti
- this was the merge request
state before the change was
push
THE MERGE REQUEST
Fixup and Autosquash // Shawn Sorichetti
- GitLab has automatically
marked the merge request as
Work in Progress
- it will not allow this merge
request to be completed until
this state is resolved.
THE MERGE REQUEST NOW
Fixup and Autosquash // Shawn Sorichetti
- GitLab has added the fact
that this code has changed
directly to the discussion
- this allows the original
reviewer to mark the
discussion as resolved
AND WHAT DOES THE FEEDBACK LOOK LIKE?
Fixup and Autosquash // Shawn Sorichetti
- once the approval is obtained, we
rebase the branch again, to squash the
fixup
- and we force push the branch to get
the clean history
- at this point the Merge Request Work
in Progress status needs to be
resolved
APPROVED
git rebase -i develop --autosquash
git push --force-with-lease origin getting_started
Fixup and Autosquash // Shawn Sorichetti
HTTPS://SSORICHE.COM/TALKS
Fixup and Autosquash // Shawn Sorichetti

Más contenido relacionado

La actualidad más candente

entwickler.de Go Day: Go Web Development 101
entwickler.de Go Day: Go Web Development 101entwickler.de Go Day: Go Web Development 101
entwickler.de Go Day: Go Web Development 101Jan Stamer
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystemJan Stamer
 
Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)lazyatom
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJan Stamer
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnitEdorian
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25Techvilla
 
ATS language overview
ATS language overviewATS language overview
ATS language overviewKiwamu Okabe
 
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Arthur Doler
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れRyuji Iwata
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
KCDC 2018 - Rapid API Development with Sails
KCDC 2018 - Rapid API Development with SailsKCDC 2018 - Rapid API Development with Sails
KCDC 2018 - Rapid API Development with SailsJustin James
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingvibrantuser
 

La actualidad más candente (17)

entwickler.de Go Day: Go Web Development 101
entwickler.de Go Day: Go Web Development 101entwickler.de Go Day: Go Web Development 101
entwickler.de Go Day: Go Web Development 101
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
 
Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnit
 
Ohh shit git
Ohh shit gitOhh shit git
Ohh shit git
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
ATS language overview
ATS language overviewATS language overview
ATS language overview
 
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れ
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
KCDC 2018 - Rapid API Development with Sails
KCDC 2018 - Rapid API Development with SailsKCDC 2018 - Rapid API Development with Sails
KCDC 2018 - Rapid API Development with Sails
 
Github flow
Github flowGithub flow
Github flow
 
Battle of the Stacks
Battle of the StacksBattle of the Stacks
Battle of the Stacks
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
 

Similar a Fixup and autosquash

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciAtlassian
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL John Anderson
 
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docx
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docxPrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docx
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docxChantellPantoja184
 
Adding Source Control to Your Life
Adding Source Control to Your LifeAdding Source Control to Your Life
Adding Source Control to Your LifeMark Kelnar
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Buildout: Fostering Repeatability
Buildout: Fostering RepeatabilityBuildout: Fostering Repeatability
Buildout: Fostering RepeatabilityClayton Parker
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X ServerYasuhiro Asaka
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainLemi Orhan Ergin
 

Similar a Fixup and autosquash (20)

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Jas bitbucket
Jas bitbucketJas bitbucket
Jas bitbucket
 
Jas bitbucket
Jas bitbucketJas bitbucket
Jas bitbucket
 
Jas bitbucket
Jas bitbucketJas bitbucket
Jas bitbucket
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docx
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docxPrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docx
PrizeExample.DS_Store__MACOSXPrizeExample._.DS_StoreP.docx
 
Adding Source Control to Your Life
Adding Source Control to Your LifeAdding Source Control to Your Life
Adding Source Control to Your Life
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Buildout: Fostering Repeatability
Buildout: Fostering RepeatabilityBuildout: Fostering Repeatability
Buildout: Fostering Repeatability
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X Server
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Capistrano
CapistranoCapistrano
Capistrano
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it Again
 

Último

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 

Fixup and autosquash

  • 1. - My name Shawn Sorichetti - going to talk about handling coding mistakes with git FIXUP AND AUTOSQUASH Shawn Sorichetti shawn@sorichetti.org https://ssoriche.com
  • 2. - I like to start git repositories with an empty commit, as it creates a rebase point at the beginning of the repository - because yes, you can make a mistake in the initial commit - creating a develop branch to follow process - and now a feature branch A LITTLE ENVIRONMENT SETUP git init . git commit -m "Initial commit" --allow-empty git checkout -b develop git checkout -b getting_started Fixup and Autosquash // Shawn Sorichetti
  • 3. - some super simple code just to get the commits going - this is far from real world, but needed something to show - Is that a good commit message? No. CREATE SOME SIMPLE CODE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; print "nHi namen"; git add my_name.pl git commit -m "Initial code commit" Fixup and Autosquash // Shawn Sorichetti
  • 4. - some super simple code just to get the commits going - this is far from real world, but needed something to show - Is that a good commit message? No. CREATE SOME SIMPLE CODE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; print "nHi namen"; git add my_name.pl git commit -m "Initial code commit" Fixup and Autosquash // Shawn Sorichetti
  • 5. - Going to introduce a change to the code CREATE A CHANGE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi namen"; git add -u git commit -m "Add newline removal" Fixup and Autosquash // Shawn Sorichetti
  • 6. - this changes the way the code works, and deserves a separate change CREATE A CHANGE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi namen"; git add -u git commit -m "Add newline removal" Fixup and Autosquash // Shawn Sorichetti
  • 7. - when I created the initial code I made a mistake, did you catch it? - failed to identify name as a variable so name is printed rather than the $name contents INITIAL MISTAKE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi namen"; Fixup and Autosquash // Shawn Sorichetti
  • 8. INITIAL MISTAKE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi $namen"; Fixup and Autosquash // Shawn Sorichetti
  • 9. INITIAL MISTAKE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi $namen"; git add -u Fixup and Autosquash // Shawn Sorichetti
  • 10. - As this was a mistake and doesn't change the story, it should not be a separate commit - just fix the existing commit - the change has been staged - but how do we deal with this mistake THEN WHAT DO YOU DO? Fixup and Autosquash // Shawn Sorichetti
  • 11. - create a new commit with a distinctive subject reminding me of what I need to do - yeah... I forgot. WHAT I USED TO DO git commit -m "XXX Rebase and fix up into Initial commit" Fixup and Autosquash // Shawn Sorichetti
  • 12. AND THEN THIS HAPPENS git checkout develop git merge getting_started git push origin develop git log origin/develop --oneline 02cde46 (HEAD -> develop) XXX Rebase and fix up into Initial commit 46c49cf Add newline removal 9a0cb79 Initial code commit cf186bb (master, develop) Initial commit Fixup and Autosquash // Shawn Sorichetti
  • 13. AND THEN THIS HAPPENS git checkout develop git merge getting_started git push origin develop git log origin/develop --oneline 02cde46 (HEAD -> develop) XXX Rebase and fix up into Initial commit 46c49cf Add newline removal 9a0cb79 Initial code commit cf186bb (master, develop) Initial commit Fixup and Autosquash // Shawn Sorichetti
  • 15. - creates a special kind of commit that includes the subject of the commit to be fixed - now this isn't really what I normally do, I use git log to find the commit and capture the SHA and just use that WHAT I SHOULD HAVE DONE git commit --fixup :/Initial Fixup and Autosquash // Shawn Sorichetti
  • 16. - which is a regex - this for instance results in the latest commit with the message matching Initial - This power by the way is brought to you by rev-parse - the --fixup argument accepts anything that git rev- parse will allow - highly recommend having a read through there - it's amazing what all can be done to specify a commit - one of which is the latest commit of the file, but that's another talk... WHAT I SHOULD HAVE DONE git commit --fixup :/Initial git help rev-parse Fixup and Autosquash // Shawn Sorichetti
  • 17. NOW MY COMMITS LOOK LIKE THIS git log --oneline 009b808 (HEAD -> getting_started) fixup! Initial code commit 46c49cf Add newline removal 9a0cb79 Initial code commit cf186bb (master, develop) Initial commit Fixup and Autosquash // Shawn Sorichetti
  • 18. - wait a minute, before you had XXX now you have fixup! - this doesn't look better HOW IS THAT BETTER? Fixup and Autosquash // Shawn Sorichetti
  • 19. AUTOSQUASH Fixup and Autosquash // Shawn Sorichetti
  • 20. - notice that git rebase moved the fixup commit into location and applies the fixup option automatically - now this is a simple example where there's only 3 commits - but imagine 20 - 40 commits, and trying to move them around - by hand AUTOSQUASH git rebase -i develop --autosquash pick 9a0cb79 Initial code commit fixup 2e72bb0 fixup! Initial code commit pick 46c49cf Add newline removal # Rebase cf186bb..2e72bb0 onto cf186bb (3 commands) # # Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash", but discard this commit's log message # x, exec <command> = run command (the rest of the line) using shell # b, break = stop here (continue rebase later with 'git rebase --continue') # d, drop <commit> = remove commit # l, label <label> = label current HEAD with a name # t, reset <label> = reset HEAD to a label # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>] # . create a merge commit using the original merge commit's # . message (or the oneline, if no original merge commit was # . specified). Use -c <commit> to reword the commit message. # # These lines can be re-ordered; they are executed from top to bottom. Fixup and Autosquash // Shawn Sorichetti
  • 21. - Because this code is so small, it does generate a merge conflict - which is pretty easy to fix - just mentioning it for completeness MERGE CONFLICT #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; <<<<<<< HEAD print "nHi namen"; ======= chomp($name); print "nHi $namen"; >>>>>>> 2e72bb0... fixup! Initial code commit Fixup and Autosquash // Shawn Sorichetti
  • 22. GREAT FOR CODE REVIEWS Fixup and Autosquash // Shawn Sorichetti
  • 23. - this is a valid concern FEEDBACK PROVIDED Fixup and Autosquash // Shawn Sorichetti
  • 24. - This is a simple fix - if condition not to print if there is no value - yes, this doesn't handle if a persons name is 0 or false FIX IT IN THE CODE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi $namen" if $name; git add -u git commit --fixup :/Initial git push origin getting_started Fixup and Autosquash // Shawn Sorichetti
  • 25. - stage the change for commit - commit the change again back to the initial commit - the history of the request is kept in the merge request, a separate commit isn't required FIX IT IN THE CODE #!/usr/bin/env perl use strict; use warnings; print "Enter your name: "; my $name = <STDIN>; chomp($name); print "nHi $namen" if $name; git add -u git commit --fixup :/Initial git push origin getting_started Fixup and Autosquash // Shawn Sorichetti
  • 26. - this was the merge request state before the change was push THE MERGE REQUEST Fixup and Autosquash // Shawn Sorichetti
  • 27. - GitLab has automatically marked the merge request as Work in Progress - it will not allow this merge request to be completed until this state is resolved. THE MERGE REQUEST NOW Fixup and Autosquash // Shawn Sorichetti
  • 28. - GitLab has added the fact that this code has changed directly to the discussion - this allows the original reviewer to mark the discussion as resolved AND WHAT DOES THE FEEDBACK LOOK LIKE? Fixup and Autosquash // Shawn Sorichetti
  • 29. - once the approval is obtained, we rebase the branch again, to squash the fixup - and we force push the branch to get the clean history - at this point the Merge Request Work in Progress status needs to be resolved APPROVED git rebase -i develop --autosquash git push --force-with-lease origin getting_started Fixup and Autosquash // Shawn Sorichetti