SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
federico.panini@fazland.com - CTO
Git in Pills
GIT Stashing
federico.panini@fazland.com - CTO
Git-Stash
save your work during work :)
federico.panini@fazland.com - CTO
The problem
When your working on a ticket to solve a bug or to implement a new feature,
frequently happens that you need to switch to another branch for solving a
problem that has occurred. So what to do ? Your actual work is in a messy state
you have new files, uncommitted ones …
Git-Stash
save your work during work :)
federico.panini@fazland.com - CTO
You could commit your amends and switch to the other branch for solve a bug:
DON’T DO IT!
You’ll loose all of the informations about your progress and also you’re storing a
commit with inconsistent code.
Git-Stash
save your work during work :)
federico.panini@fazland.com - CTO
How can I leave the state of my current branch clean, and switching to another
branch ?
use GIT STASH
Using git stash will allow you to maintain the dirty state of your current working
directory and saves it on a stack of unfinished changes that you can reapply
at any time.
Git-Stash
how to use it ? - stash p. 1
federico.panini@fazland.com - CTO
Stashing your current files is easy and simple: in your directory where messy
files are type:
$ git status
# On branch feature/610_i18N_de_ro
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: routing_de.yml
# modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php
# modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#
# modified: scripts/crontab
#
You’ll see a list of unstaged files.
Git-Stash
how to use it ? - stash p. 2
federico.panini@fazland.com - CTO
Stashing your current files is easy and simple: in your directory where messy
files are now type:
$ git stash
Saved working directory and index state 
"WIP on feature/610_i18N_de_ro: 049d078 added the index file"
HEAD is now at 049d078 added the index file
(To restore them type "git stash apply")
Now your working directory is clear
$ git status
# On branch feature/610_i18N_de_ro
nothing to commit, working directory clean
at this point you can freely switch to another branch do whatever you need to
do to fix bugs or implement new feature
Git-Stash
how to use it ? - stash p. 3
federico.panini@fazland.com - CTO
Where are your stashed files now ?
$ git stash list
stash@{0}: WIP on feature/610_i18N_de_ro: 049d078 added the index file
stash@{1}: WIP on feature/610_i18N_de_ro: c264051 Revert "added file_size"
stash@{2}: WIP on feature/610_i18N_de_ro: 21d80a5 added number to log
You can see a list of stashes and the first one (stash{0}) is the last that you
created. At any time you can get the stash back.
Git-Stash
how to use it ? - stash p. 4
federico.panini@fazland.com - CTO
How to stash back your files ?
$ git stash apply --index
# On branch feature/610_i18N_de_ro
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: routing_de.yml
# modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php
# modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#
# modified: scripts/crontab
#
When your critical bug fixing is done you can get the files back from the stash
and continue you development on that files
Git-Stash
BEST PRACTISES - stash message
federico.panini@fazland.com - CTO
If you don’t give a message comment to a stash git automatically creates it
taken it from the last commit log message. This could be a bit confusing when
your working with multiple stash and could lead to errors … huge errors!
So the adivice is to use git stash save “message”.
This command is equal to git stash with the difference that you can give a
message name to the stash
$ git stash save “stash fiels for #610 working progress on upload image bug fixing ”
# On branch feature/610_i18N_de_ro
# Changes to be committed:
Git-Stash
BEST PRACTISES - stash lifetime p.1
federico.panini@fazland.com - CTO
Git Stash is used for switching quickly between branches when you have to
work on multiple different tasks, or when suddenly you have to fix a critical bug.
Considering that the stash is “shared” between all the git repository it is not
absolutely advised to leave the code in the stash for a long period. The stash is
a quick “knife tool” which will help you with sudden “code” events.
Git-Stash
BEST PRACTISES - stash lifetime p.2
federico.panini@fazland.com - CTO
If you plan to work on a new feature for
a long time period, instead of putting
the working files your on in the stash
you can create a branch for them:
BRANCH IT!
$ git stash branch testchanges
Switched to a new branch "testchanges"
# On branch testchanges
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: routing_de.yml
# modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php
# modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#
# modified: scripts/crontab
#
Dropped refs/stash@{0} (f0dfc4d5dc332d1cee34a634182e168c4efc3359)
Git-Stash
dropping a stash
federico.panini@fazland.com - CTO
When your stash has been got back you can delete it. Remember that it’s
always a best practice to delete your stash just after you got back from stash
stack.
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
Git-Stash
Command reference
federico.panini@fazland.com - CTO
• git stash list
• git stash
• git stash save message
• git stash apply —index
• git stash drop stash{n}
• git stash branch branchname
Git-Stash
Reference
federico.panini@fazland.com - CTO
• http://git-scm.com/book/en/v1/Git-Tools-Stashing
• https://www.kernel.org/pub/software/scm/git/docs/git-stash.html
• http://gitready.com/beginner/2009/01/10/stashing-your-changes.html

Más contenido relacionado

La actualidad más candente

Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails UndergroundAriejan de Vroom
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
 
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Codemotion
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubNick Quaranto
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitRick Umali
 
Using Git on the Command Line
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command LineBrian Richards
 
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburgmsohn
 
Bedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBeDjango
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with GitRick Umali
 
#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remotoRodrigo Branas
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Gitgittower
 

La actualidad más candente (20)

Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git basics : a beginner's guide
Git basics : a beginner's guideGit basics : a beginner's guide
Git basics : a beginner's guide
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Using Git on the Command Line
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command Line
 
Git github
Git githubGit github
Git github
 
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
Git Tricks
Git TricksGit Tricks
Git Tricks
 
Bedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHub
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with Git
 
#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto
 
Git operation 101
Git operation 101Git operation 101
Git operation 101
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
 

Similar a Git in pills : git stash

Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__greyKing Hom
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__whiteKing Hom
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_darkKing Hom
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
WPGR - Intro to Git (on the Command Line)
WPGR - Intro to Git (on the Command Line)WPGR - Intro to Git (on the Command Line)
WPGR - Intro to Git (on the Command Line)Brian Richards
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - WorkflowTahsin Abrar
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for GitJan Krag
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced gitGerrit Wanderer
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 

Similar a Git in pills : git stash (20)

Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Gittalk
GittalkGittalk
Gittalk
 
Git
GitGit
Git
 
WPGR - Intro to Git (on the Command Line)
WPGR - Intro to Git (on the Command Line)WPGR - Intro to Git (on the Command Line)
WPGR - Intro to Git (on the Command Line)
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Git and github
Git and githubGit and github
Git and github
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 

Más de Federico Panini

Long life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadFederico Panini
 
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...Machine Learning: strategie di collaborative filtering nelle piattaforme onli...
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...Federico Panini
 
Vagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headlessVagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headlessFederico Panini
 
Aws vpc : addressing cidr
Aws vpc : addressing cidrAws vpc : addressing cidr
Aws vpc : addressing cidrFederico Panini
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Federico Panini
 
Elasticsearch a quick introduction
Elasticsearch a quick introductionElasticsearch a quick introduction
Elasticsearch a quick introductionFederico Panini
 
Elk - Elasticsearch Logstash Kibana stack explained
Elk - Elasticsearch Logstash Kibana stack explainedElk - Elasticsearch Logstash Kibana stack explained
Elk - Elasticsearch Logstash Kibana stack explainedFederico Panini
 

Más de Federico Panini (8)

Long life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is dead
 
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...Machine Learning: strategie di collaborative filtering nelle piattaforme onli...
Machine Learning: strategie di collaborative filtering nelle piattaforme onli...
 
Vagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headlessVagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headless
 
Aws vpc : addressing cidr
Aws vpc : addressing cidrAws vpc : addressing cidr
Aws vpc : addressing cidr
 
Symfony & Mailcatcher
Symfony & MailcatcherSymfony & Mailcatcher
Symfony & Mailcatcher
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)
 
Elasticsearch a quick introduction
Elasticsearch a quick introductionElasticsearch a quick introduction
Elasticsearch a quick introduction
 
Elk - Elasticsearch Logstash Kibana stack explained
Elk - Elasticsearch Logstash Kibana stack explainedElk - Elasticsearch Logstash Kibana stack explained
Elk - Elasticsearch Logstash Kibana stack explained
 

Último

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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Último (20)

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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Git in pills : git stash

  • 2. Git in Pills GIT Stashing federico.panini@fazland.com - CTO
  • 3. Git-Stash save your work during work :) federico.panini@fazland.com - CTO The problem When your working on a ticket to solve a bug or to implement a new feature, frequently happens that you need to switch to another branch for solving a problem that has occurred. So what to do ? Your actual work is in a messy state you have new files, uncommitted ones …
  • 4. Git-Stash save your work during work :) federico.panini@fazland.com - CTO You could commit your amends and switch to the other branch for solve a bug: DON’T DO IT! You’ll loose all of the informations about your progress and also you’re storing a commit with inconsistent code.
  • 5. Git-Stash save your work during work :) federico.panini@fazland.com - CTO How can I leave the state of my current branch clean, and switching to another branch ? use GIT STASH Using git stash will allow you to maintain the dirty state of your current working directory and saves it on a stack of unfinished changes that you can reapply at any time.
  • 6. Git-Stash how to use it ? - stash p. 1 federico.panini@fazland.com - CTO Stashing your current files is easy and simple: in your directory where messy files are type: $ git status # On branch feature/610_i18N_de_ro # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: routing_de.yml # modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php # modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # # modified: scripts/crontab # You’ll see a list of unstaged files.
  • 7. Git-Stash how to use it ? - stash p. 2 federico.panini@fazland.com - CTO Stashing your current files is easy and simple: in your directory where messy files are now type: $ git stash Saved working directory and index state "WIP on feature/610_i18N_de_ro: 049d078 added the index file" HEAD is now at 049d078 added the index file (To restore them type "git stash apply") Now your working directory is clear $ git status # On branch feature/610_i18N_de_ro nothing to commit, working directory clean at this point you can freely switch to another branch do whatever you need to do to fix bugs or implement new feature
  • 8. Git-Stash how to use it ? - stash p. 3 federico.panini@fazland.com - CTO Where are your stashed files now ? $ git stash list stash@{0}: WIP on feature/610_i18N_de_ro: 049d078 added the index file stash@{1}: WIP on feature/610_i18N_de_ro: c264051 Revert "added file_size" stash@{2}: WIP on feature/610_i18N_de_ro: 21d80a5 added number to log You can see a list of stashes and the first one (stash{0}) is the last that you created. At any time you can get the stash back.
  • 9. Git-Stash how to use it ? - stash p. 4 federico.panini@fazland.com - CTO How to stash back your files ? $ git stash apply --index # On branch feature/610_i18N_de_ro # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: routing_de.yml # modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php # modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # # modified: scripts/crontab # When your critical bug fixing is done you can get the files back from the stash and continue you development on that files
  • 10. Git-Stash BEST PRACTISES - stash message federico.panini@fazland.com - CTO If you don’t give a message comment to a stash git automatically creates it taken it from the last commit log message. This could be a bit confusing when your working with multiple stash and could lead to errors … huge errors! So the adivice is to use git stash save “message”. This command is equal to git stash with the difference that you can give a message name to the stash $ git stash save “stash fiels for #610 working progress on upload image bug fixing ” # On branch feature/610_i18N_de_ro # Changes to be committed:
  • 11. Git-Stash BEST PRACTISES - stash lifetime p.1 federico.panini@fazland.com - CTO Git Stash is used for switching quickly between branches when you have to work on multiple different tasks, or when suddenly you have to fix a critical bug. Considering that the stash is “shared” between all the git repository it is not absolutely advised to leave the code in the stash for a long period. The stash is a quick “knife tool” which will help you with sudden “code” events.
  • 12. Git-Stash BEST PRACTISES - stash lifetime p.2 federico.panini@fazland.com - CTO If you plan to work on a new feature for a long time period, instead of putting the working files your on in the stash you can create a branch for them: BRANCH IT! $ git stash branch testchanges Switched to a new branch "testchanges" # On branch testchanges # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: routing_de.yml # modified: src/Fazland/WebsiteBundle/Controller/QuoteController.php # modified: src/Fazland/WebsiteBundle/Controller/SettingsController.php # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # # modified: scripts/crontab # Dropped refs/stash@{0} (f0dfc4d5dc332d1cee34a634182e168c4efc3359)
  • 13. Git-Stash dropping a stash federico.panini@fazland.com - CTO When your stash has been got back you can delete it. Remember that it’s always a best practice to delete your stash just after you got back from stash stack. $ git stash drop stash@{0} Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
  • 14. Git-Stash Command reference federico.panini@fazland.com - CTO • git stash list • git stash • git stash save message • git stash apply —index • git stash drop stash{n} • git stash branch branchname
  • 15. Git-Stash Reference federico.panini@fazland.com - CTO • http://git-scm.com/book/en/v1/Git-Tools-Stashing • https://www.kernel.org/pub/software/scm/git/docs/git-stash.html • http://gitready.com/beginner/2009/01/10/stashing-your-changes.html