Learn the intricacies of Git commands and explore career advancement through coding classes. This guide offers helpful syntax for stashing, listing, restoring, and removing stashes in Git, as well as information about relevant courses in web development, Python, data science, and web design.
Key Insights
- To stash uncommitted code for later use in Git, utilize the commands 'git stash' or 'git stash save "A meaningful name/message". Multiple stashes can be created and named for easy identification.
- 'git stash list' command is used to see a list of your stashes.
- Restoration of the latest stash can be accomplished with the 'git stash pop' command. This command can also be used to apply a specific stash and remove it from the stash list or apply a specific stash and keep it in the stash list.
- Deletion of all stashes is done using the 'git stash clear' command. A specific stash can be removed by using the 'git stash drop stash@{0}' command.
- Furthering one's education in coding can open up new career opportunities. Courses offered include web development, Python, data science, and web design.
- Small, hands-on, and expert-led classes are available at the NYC web development school, NYC Python bootcamp, NYC data science school, and NYC web design school.
The Git Stash as a place to temporarily store that's not ready to be permanently stored in a commit. Let's say you're working on some code that you're not ready to commit. You get a request to make a change and push the code. What do you do with the other code you've been working on? You can stash it away, do your work, and bring the code back from the stash.
For All the Commands Below
The commands below assume you've navigated to the folder for the Git repo.
Create a Stash
To stash away your uncommitted code for later, run one of these commands:
- Git stash
- Git stash save "A meaningful name/message"
- NOTE: You can have multiple stashes. You're not required to name each stash, but you may want to give it a meaningful name.
List Stashes
To see a list of your stashes, run this command:
- Git stash list
Restore/Apply a Stash
To apply the latest stash, run this command:
-
Git stash pop
- To apply a specific stash (and remove it from the stash list), run the following command. (Replace stash@{0} with the stash you want to restore, which you find in the list of stashes):
-
Git stash pop stash@{0}
- To apply a specific stash (and keep it in the stash list), run the following command. (Replace stash@{0} with the stash you want to restore, which you find in the list of stashes):
- Git stash apply stash@{0}
Removing Stashes
To deletes all stashes, run this command:
- Git stash clear
To delete a specific stash, run the following command. (Replace stash@{0} with the stash you want to delete, which you find in the list of stashes):
- Git stash drop stash@{0}
Go Beyond Git
We offer a full suite of coding courses. Classes are small, hands-on, and expert-led. Check out our coding bootcamps and schools now: