1.

When should we use GIT stash?

Answer»

This command saves our local modifications and reverts the working directory to match the HEAD commit of the repository. The changes stashed away by above command can be listed with GIT STASH list, and checked with git stash show, and restored with git stash apply. We can understand this scenario with the below examples. In the below code we have modified one file (index.html) and added new file stsyle.css in the repository.

$ git status On branch master Changes to be committed: new file: style.css Changes are not staged for commit: modified: index.html $ git stash Saved working directory and index state WIP on master: 5002d47 our new homepage HEAD is now at 5002d47 our new homepage $ git status On branch master nothing to commit, working tree clean

There are LOTS of scenarios where we would be NEEDING a clean working copy as recommended or even required: This situation arises when merging branches, when pulling from a remote, or simply when checking out a different branch.

The "git stash" command always help us to (temporarily but safely) and store our uncommitted local changes - and leave us with a clean working copy. Continuing Where You Left Off

As already mentioned, Git's Stash is meant as temporary storage. When you're ready to continue where you left off, you can restore the saved state easily: $ git stash pop



Discussion

No Comment Found