Git Learning notes 05--git stash

Source: Internet
Author: User
Tags diff reset
git learning notes 05--git stash

An excerpt from the Git authoritative guide

Git stash is used to save and restore work progress.

Git stash

Saves the current work progress. The state of the staging area and workspace are saved separately.

git stash List

Displays a list of progress. This command clearly implies that git stash can save the work progress multiple times and select it at the time of recovery.

git stash pop [--index] [<stash>]

If you do not use any parameters, the latest saved work progress is restored and the work progress of the recovery is purged from the stored work progress list.

If you provide a <stash> parameter (from the list displayed by the Git stash), recover from that <stash>. The restore will also remove <stash> from the progress list.

Option--index try to restore staging area in addition to the files in the workspace. This is why the status shown at the beginning of this chapter is slightly different from the time it was saved before the progress was resumed.

git stash [save [--patch] [-k|--[no]keep-index] [-q|--quiet] [<message>]

This command is actually the full version of the first git stash command. That is, if you need to use the specified description when saving your work progress, you must use the following format:

Git stash save "message ..."

Using the parameter--patch will show the difference between the workspace and head, and by editing the diff file, you can exclude extraneous content from the progress by editing the diff file to determine the content of the workspace that will eventually be saved in progress.

Using the-K or the--keep-index parameter, the staging area is not reset after the progress is saved. By default, the staging area and workspace are forced to reset.

git stash apply [--index] [<stash>]

In addition to not removing the progress of the recovery, the rest is the same as the Git stash pop command.

git stash drop [<stash>]

Deletes the progress of a store. The latest progress is deleted by default.

Git stash Clear

Deletes the progress of all the stores.

git Stash Branch <branchname> <stash>

Create a branch based on progress.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.