Stash

WHAT IS GIT STASH?

  • According to git documentation: when you want to register the current state of the work directory and index, but you want to go back to a clean working directory.

Translating: We are working on the project and Want to get back to having that information you had in the last commit, removing all changes from the current job and saving in a temporary branch, write < git stash >

How does it work?

  • It creates a backup of your work actsl and sends to a temporary branch, let's go to practice:

I'll do a < git log > to see how my local repository is doing.

commit 0418ff253f00195b3a7062e6829ac8f17f10ee61 (HEAD -> master, functionality1)
Date: Wed Jul 15 17:02:33 2020 -0300

modifying files

commit A3559328f7ce4ed5799d4e7a8efed964058d003b
Date: Wed Jul 15 16:55:11 2020 -0300

sixth commit

commit 893a770bebd84721b9cd6d7fd9eb52FB90160458
Date: Wed Jul 15 16:50:06 2020 -0300

Creating a new feature

commit 44013a9a0a2225ce100b3e59f5544883d06db489
Date: Wed Jul 15 14:42:30 2020 -0300

fifth commit

commit 5A45c7bb47365dfb6c43cc40e0f6b7b44a34c8b9
Date: Wed Jul 15 14:41:25 2020 -0300

adding git ignore

Next we will work on a file, but we do not want to add to git and not much less commit, so we will make a git stash.

$ git stash

If we look at the files you changed, it won't have your changes, because git backed up your changes and sent it to a separate branch.

This command can be done as many times as you want, turning the stash into a stack

LIST:

To list all stash:

$ git stash list

stash@{0}: WIP on master: 0418ff2 modifying files
stash@{1}: WIP on master: 0418ff2 modifying files
(END)

DELETE:

$git stash clear

Note: This will delete the saved work

RETURN:

$ git stash pop

Notes:

  • Return is a stack.
  • Possible when you return your changes, conflict may occur.

 

results matching ""

    No results matching ""