Git in pills : git stash

Federico Panini
Federico PaniniCTO @ Fazland.com, Team Leader, Senior Developer, Aws Certified Solutions Architect - Associate level
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
1 of 15

Recommended

How to become a Git power user by
How to become a Git power userHow to become a Git power user
How to become a Git power userDeveo
663 views17 slides
Git essentials by
Git essentialsGit essentials
Git essentialsMatthew Barlocker
3.9K views23 slides
Improving your workflow with git by
Improving your workflow with gitImproving your workflow with git
Improving your workflow with gitDídac Ríos
251 views37 slides
Advanced Git by
Advanced GitAdvanced Git
Advanced GitSergiu-Ioan Ungur
1K views92 slides
Git basic and workflow by
Git basic and workflowGit basic and workflow
Git basic and workflowbuikhanhbk
129 views21 slides
Git Distributed Version Control System by
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
825 views51 slides

More Related Content

What's hot

Git Basics at Rails Underground by
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails UndergroundAriejan de Vroom
1.6K views48 slides
Git: basic to advanced by
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
1.3K views22 slides
Juliette Reinders Folmer - Promote your open source project with GitHub Pages... by
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
345 views57 slides
Git and git workflow best practice by
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
3.6K views31 slides
Git basics : a beginner's guide by
Git basics : a beginner's guideGit basics : a beginner's guide
Git basics : a beginner's guideDigital Product School
272 views16 slides
Git Magic: Versioning Files like a Boss by
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
2.2K views111 slides

What's hot(20)

Git: basic to advanced by Yodalee
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee1.3K views
Juliette Reinders Folmer - Promote your open source project with GitHub Pages... by Codemotion
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...
Codemotion345 views
Git and git workflow best practice by Majid Hosseini
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini3.6K views
Git Magic: Versioning Files like a Boss by tmacwilliam
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
tmacwilliam2.2K views
Open Source Collaboration With Git And Git Hub by Nick Quaranto
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
Nick Quaranto1.8K views
Introduction to Git by Rick Umali
Introduction to GitIntroduction to Git
Introduction to Git
Rick Umali933 views
Using Git on the Command Line by Brian Richards
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command Line
Brian Richards977 views
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg by msohn
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
msohn1.1K views
Bedjango talk about Git & GitHub by BeDjango
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHub
BeDjango673 views
Getting Started with Git by Rick Umali
Getting Started with GitGetting Started with Git
Getting Started with Git
Rick Umali482 views
#5 - Git - Contribuindo com um repositório remoto by Rodrigo Branas
#5 - Git - Contribuindo com um repositório remoto#5 - Git - Contribuindo com um repositório remoto
#5 - Git - Contribuindo com um repositório remoto
Rodrigo Branas1.1K views
Undoing Things in Git by gittower
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
gittower7.1K views

Similar to Git in pills : git stash

Wokshop de Git by
Wokshop de Git Wokshop de Git
Wokshop de Git Alberto Leal
401 views48 slides
Introduction to Git for Artists by
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
4.4K views61 slides
Git cheat sheet_dark by
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_darkKing Hom
326 views2 slides
Git cheat sheet__white by
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__whiteKing Hom
282 views2 slides
Git cheat sheet__grey by
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__greyKing Hom
267 views2 slides
How to Really Get Git by
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
1.8K views57 slides

Similar to Git in pills : git stash(20)

Introduction to Git for Artists by David Newbury
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury4.4K views
Git cheat sheet_dark by King Hom
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom326 views
Git cheat sheet__white by King Hom
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom282 views
Git cheat sheet__grey by King Hom
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom267 views
How to Really Get Git by Susan Tan
How to Really Get GitHow to Really Get Git
How to Really Get Git
Susan Tan1.8K views
WPGR - Intro to Git (on the Command Line) by Brian Richards
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 Richards659 views
Mastering git - Workflow by Tahsin Abrar
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar436 views
Jedi Mind Tricks for Git by Jan Krag
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
Jan Krag2K views
Matt Gauger - Git & Github web414 December 2010 by Matt Gauger
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
Matt Gauger1.7K views
GIT in a nutshell by alignan
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan309 views
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017 by Codemotion
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Codemotion398 views

More from Federico Panini

Long life to vagrant… Vagrant is dead by
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadFederico Panini
1.4K views73 slides
Machine Learning: strategie di collaborative filtering nelle piattaforme onli... by
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
189 views16 slides
Vagrant boxes with x, export display, chrome headless by
Vagrant boxes with x, export display, chrome headlessVagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headlessFederico Panini
758 views21 slides
Aws vpc : addressing cidr by
Aws vpc : addressing cidrAws vpc : addressing cidr
Aws vpc : addressing cidrFederico Panini
1K views8 slides
Symfony & Mailcatcher by
Symfony & MailcatcherSymfony & Mailcatcher
Symfony & MailcatcherFederico Panini
2.5K views17 slides
Elasticsearch quick Intro (English) by
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Federico Panini
1.5K views73 slides

More from Federico Panini(8)

Long life to vagrant… Vagrant is dead by Federico Panini
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is dead
Federico Panini1.4K views
Machine Learning: strategie di collaborative filtering nelle piattaforme onli... by Federico 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...
Federico Panini189 views
Vagrant boxes with x, export display, chrome headless by Federico Panini
Vagrant boxes with x, export display, chrome headlessVagrant boxes with x, export display, chrome headless
Vagrant boxes with x, export display, chrome headless
Federico Panini758 views
Elasticsearch quick Intro (English) by Federico Panini
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)
Federico Panini1.5K views
Elasticsearch a quick introduction by Federico Panini
Elasticsearch a quick introductionElasticsearch a quick introduction
Elasticsearch a quick introduction
Federico Panini3.9K views
Elk - Elasticsearch Logstash Kibana stack explained by Federico Panini
Elk - Elasticsearch Logstash Kibana stack explainedElk - Elasticsearch Logstash Kibana stack explained
Elk - Elasticsearch Logstash Kibana stack explained
Federico Panini1.3K views

Recently uploaded

STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
12 views1 slide
Voice Logger - Telephony Integration Solution at Aegis by
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
17 views1 slide
Web Dev - 1 PPT.pdf by
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdfgdsczhcet
55 views45 slides
Data-centric AI and the convergence of data and model engineering: opportunit... by
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...Paolo Missier
34 views40 slides
Special_edition_innovator_2023.pdf by
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdfWillDavies22
16 views6 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
120 views17 slides

Recently uploaded(20)

STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 views
Web Dev - 1 PPT.pdf by gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet55 views
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier34 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2216 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi120 views
AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS27 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 views
How the World's Leading Independent Automotive Distributor is Reinventing Its... by NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 views
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... by Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin75 views
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... by NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS37 views
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... by NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS16 views
Future of Learning - Yap Aye Wee.pdf by NUS-ISS
Future of Learning - Yap Aye Wee.pdfFuture of Learning - Yap Aye Wee.pdf
Future of Learning - Yap Aye Wee.pdf
NUS-ISS41 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 views

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