-2

I am reading https://stackoverflow.com/a/6925136/156458 for learning git stash.

I was wondering if git stash save in the first method and git stash in the second are the same? What difference does save make?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Tim
  • 1
  • 141
  • 372
  • 590

3 Answers3

4

Yes, they are the same.

With git stash save you can provide an optional message that will be used for the stash, so it can be found more easily in the future.

knittl
  • 246,190
  • 53
  • 318
  • 364
2

A quick quote from the documentation of git stash:

DESCRIPTION

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and restored (potentially on top of a different commit) with git stash apply. Calling git stash without any arguments is equivalent to git stash save.

axiac
  • 68,258
  • 9
  • 99
  • 134
0

Now, git stash save has been deprecated, and now we should use git stash push.

  • git stash push will stash tracked files
  • git stash push -u will stash untracked files
  • git stash push -a will stash ignored files

More information is here

Muhammad Tariq
  • 3,318
  • 5
  • 38
  • 42