What is git stash & How to git stash Apply

Git Stash is a distributed Version control tool. Git that locally stores all the most recent changes in a workspace. it’s means git stash to store safely in a hidden place (the stash stack).

What is git stash & How to git stash Apply

Step : How to git stash Apply

Step 1: Git stash

Use ” Cat ” command to create new git code file and write something on that file “Ex: This is my code which I will store in stash” and “Ctrl+D” to save.

# cat >workfile
# git status

# cat >workfile

# git add .
# git commit -m “stash commit”
# git log –oneline

git add

Open same file “workfile” add something new cord

# vi workfile

Use ” git stash ” command to save working code into stash
Note: stash will save before “add and commite

# cat workfile
# git stash

Step 2 : git stash list

Use “git stash list” command to check stash storage

# git stash list

add something on that file

# vi workfile

Now that are showing my second stash ” stash@ {1}

# git stash
# git stash list

# cat workfile

Step 3: git stash apply

# git stash apply stash@{0}

# cat workingfile

Now, you can “add and commit” restore stash data

# git add.
# git commit -m “stash file commit”

Restore, another stash data

# git stash apply stash@{1}
# vi workingfile

change and arrange restore stash data

# git add.
# git commit -m “conflit file commit”

Check final commit data

# git status
# git log –oneline

Step 4: git stash clear

If, you want to clean all stash date after restore use “git stash clear”

# git stash list
# git stash clear
# git stash list

Install Git in Linux | Git log, Push, Pull

Install Git in Linux Git log, Push, Pull
  • Install Git
  • Set up Git
  • Create working file
  • Check git log
  • Create GitHub Account
  • Generate and copy 2FA password
  • Push and Pull working data to Github account for use world wide.


How to git branch Create, Delete, Rename

How to git branch Create, Delete, Rename
  • create a code and commit
  • Create new branch
  • Code add and commit in new branch
  • Rename branch
  • Delete branch

Git Merge branch and Conflict – Step By Step

Git Merge branch and Conflict - Step By Step
  • Create branch
  • Git Merge branch create
  • Conflict branch
5/5 - (1 vote)
Sharing Is Caring:

2 thoughts on “What is git stash & How to git stash Apply”

  1. I simply could not depart your website prior to suggesting that I extremely enjoyed the standard information an individual supply on your visitors? Is going to be back steadily to investigate cross-check new posts.

    Reply
  2. It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

    Reply

Leave a Comment