Check Last commit vs Stash

Soufiane Oucherrou
3 min readNov 14, 2019

--

In this article I will talk about how to check your last commit and how to use stash command

Temporarily Checkout a Previous Commit

By “reverting a commit”, you might mean that you temporarily want to go back to a previous state in your repo, but without making any actual changes to the tree. In this case you’d probably just want to checkout the commit, allowing you to go back to master or any other state when you’re done First of all Run this command

git log

you will get all your commits you made so far for your project, for us we want to check the previous one, which is going to be the first one show up in your terminal

Copy your hash key and run this code

This will change your working directory to the contents of that commit, as well . Any changes you make here can either be committed to a branch or stashed for later use.

git stash: a Clipboard for Your Changes

Let’s say you currently have a couple of local modifications:

If you have to switch context — e.g. because you need to work on an urgent bug — you need to get these changes out of the way. You shouldn’t just commit them, of course, because it’s unfinished work.

This is where “git stash” comes in handy:

Your working copy is now clean: all uncommitted local changes have been saved on this kind of “clipboard” that Git’s Stash represents. You’re ready to start your new task

Continuing Where You Left Off

As already mentioned, Git’s Stash is meant as a temporary storage. When you’re ready to continue where you left off, you can restore the saved state easily: by typing this code ‘git stash pop’ and your will get pull last stash you made

now you can start working on last thing you being working on before you stash it.

last thing u can do is to delete all you stashes by running git stash drop and won’t have access to stashes anymore

--

--

No responses yet