Git Stash Tutorial ~ How to Shelve Changes for Later

  Рет қаралды 858

Cameron McKenzie

Cameron McKenzie

4 ай бұрын

Git Stash is a feature in Git that allows you to save changes that are not ready to be committed but need to be temporarily set aside. This git stash tutorial for beginners will show you exactly how to use git stash to temporary shelve changes.
This can be useful when you want to switch branches or work on a different task without committing your current changes.
Here are the main commands associated with Git Stash:
1. git stash save "message":
- This command is used to stash changes in your working directory. The message is optional but can be helpful for identifying the stash later.
git stash save "Work in progress on feature X"
2. git stash list:
- Shows a list of stashes you've created. Each stash is assigned a unique identifier (e.g., stash@{0}, stash@{1}, etc.).
git stash list
3. git stash show:
- Displays the changes that are in the latest stash. This is useful for reviewing the changes before applying or popping the stash.
git stash show
4. git stash apply [stash_id]:
- Applies the changes from the specified stash on top of your working directory. If no stash ID is provided, it applies the latest stash.
git stash apply stash@{1}
5. git stash pop [stash_id]:
- Similar to `git stash apply`, but it also removes the applied stash from the stash list. If no stash ID is provided, it pops the latest stash.
git stash pop stash@{2}
6. git stash drop [stash_id]:
- Deletes a stash from the stash list. If no stash ID is provided, it deletes the latest stash.
git stash drop stash@{0}
7. git stash clear:
- Removes all stashes. This command is used when you want to clear all the stashed changes.
git stash clear
Git Stash is a convenient tool for temporarily saving changes, and you can use commands like `git stash list`, `git stash show`, `git stash apply`, `git stash pop`, `git stash drop`, and `git stash clear` to manage and interact with your stashes.

Пікірлер: 7
@thankgodmudnoe3524
@thankgodmudnoe3524 27 күн бұрын
A million thanks for the video
@AfmpJR
@AfmpJR Ай бұрын
Man! you did that so great. Thanks.
@cameronmcnz
@cameronmcnz Ай бұрын
The git stash command is the unsung hero of version control. Happy to share my affection for it!
@umdesch4
@umdesch4 2 ай бұрын
Appreciate the info, and the Jocko Homo reference. :)
@cameronmcnz
@cameronmcnz 2 ай бұрын
You're an old schooler like me, obviously.
@pravinprince3221
@pravinprince3221 4 ай бұрын
Thank you for the video sir We love your videos and thanks for the effort sir it is so helpful for the team and myself sir, thanks again
@cameronmcnz
@cameronmcnz 4 ай бұрын
Thanks so much for the kind words. Say 'Hi' to the team, and let me know if there are any good topics I should cover!
Git and GitHub Crash Course For Beginners | Complete Tutorial [2024]
1:53:19
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 263 М.
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 64 МЛН
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 95 МЛН
How to Generate GitHub SSH Keys
19:15
Cameron McKenzie
Рет қаралды 8 М.
Java Constructors Tutorial
15:25
Cameron McKenzie
Рет қаралды 473
How to Push an Existing Project to GitLab
19:14
Cameron McKenzie
Рет қаралды 3 М.
Git MERGE vs REBASE: The Definitive Guide
9:39
The Modern Coder
Рет қаралды 88 М.
Creator of git, Linus Torvalds Presents the Fundamentals of git
1:10:15
Developers Alliance
Рет қаралды 13 М.
How to Undo a Pushed Git Commit - Reset & Revert a Git Commit After Push
12:25
Generate GitLab SSH Keys & setup SSH on GitLab
14:32
Cameron McKenzie
Рет қаралды 9 М.
Git STASH Tutorial
6:59
The Modern Coder
Рет қаралды 22 М.
git rebase - Why, When & How to fix conflicts
9:45
Philomatics
Рет қаралды 30 М.
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00