shelve
git shelve
is not a native Git command, but it is a concept similar to git stash
that can be implemented using Git's features. Shelving changes allows you to temporarily set aside changes in your working directory without committing them, similar to stashing.
Basic Usage
Shelve Changes
To shelve changes, you can use
git stash
to save your current changes:git stash push -m "Shelve: <description>"This command stashes your changes with a message describing the shelve.
List Shelved Changes
To list all stashed (shelved) changes, use:
git stash listThis will show a list of all stashed changes.
Apply Shelved Changes
To apply shelved changes back to your working directory, use:
git stash apply <stash@{n}>Replace
<stash@{n}>
with the identifier of the stash you want to apply.Drop Shelved Changes
To remove a specific shelved change, use:
git stash drop <stash@{n}>Replace
<stash@{n}>
with the identifier of the stash you want to drop.
Examples
Shelve Changes with a Description
git stash push -m "Shelve: WIP on feature-x"This command stashes your current changes with the message "Shelve: WIP on feature-x".
List All Shelved Changes
git stash listThis command lists all stashed changes.
Apply a Specific Shelved Change
git stash apply stash@{1}This command applies the changes from the stash with identifier
stash@{1}
.Drop a Specific Shelved Change
git stash drop stash@{1}This command drops the stash with identifier
stash@{1}
.
Using these commands, you can effectively manage shelved changes in your Git repository.