Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Git Best Practices Guide

You're reading from   Git Best Practices Guide Master the best practices of Git with the help of real-time scenarios to maximize team efficiency and workflow

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783553730
Length 102 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
PIDOUX Eric PIDOUX Eric
Author Profile Icon PIDOUX Eric
PIDOUX Eric
Arrow right icon
View More author details
Toc

Stashing your changes

Git has a command that allows you to save the current state of the local working repository and go back to the last committed revision with git stash.

This is really helpful when you have to develop an urgent fix. After this, you can restore the stashed changes and continue with your development.

To use this command, just execute the following command snippet:

Erik@server:~$ git stash
#Do your fix and then unstash edit
Erik@server:~$ git stash pop

Of course, you can do more with this command, such as save a list of stashes:

Erik@server:~$ git stash
#See the list of available stashes
Erik@server:~$ git stash list
#Apply the second stash
Erik@server:~$ git stash apply stash@"1}
#Delete a stash
Erik@server:~$ git stash drop stash@"1}
#Or delete all stashes
Erik@server:~$ git stash clear

Let's suppose that your stash concerns a feature and you haven't created a dedicated branch for it. You can simply create a branch executing this command:

Erik@server:~...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime