Lets assume one scenario :

  1. Currently I'm on Master branch.
  2. I make a new branch and switch to it.
  3. I do some new work, but don't make any commits.

What happens when I switch back to master?

  1. Either My changes come with me to the destination branch.
  2. Or Git won't let me switch if it detects potential conflicts.

Git Stashing

Git provides an easy way of stashing these uncommitted changes so that we can return to them later, without having to make unnecessary commits.

	
	git stash
	
	git stash pop
	

git stash is super useful command that helps us save changes that are not yet ready to commit. we can stash changes and then come back to them later. Running git stash will take all uncommitted changes (staged and unstaged) and stash them, reverting the changes in our working copy.

git stash pop to remove the most recently stashed changes in our stash and re-apply them to our working copy.


Git stash apply

	
	git stash apply
	
	
	git stash -u
	
	
	git stash
		do some other stuff...
		
	git stash
		do some other stuff...
		
	git stash
	
	
	git stash list
	
	
	git stash apply [stash_id]
	
	
	git stash drop [stash_id]
	
	
	git stash clear