git - See what's in a stash without applying it

ID : 363

viewed : 38

Tags : gitgit-stashgit

Top 5 Answer for git - See what's in a stash without applying it

vote vote

98

From man git-stash (which can also be obtained via git help stash):

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and ...

show [<stash>]     Show the changes recorded in the stash as a diff between the stashed     state and its original parent. When no <stash> is given, shows the     latest one. By default, the command shows the diffstat, but it will     accept any format known to git diff (e.g., git stash show -p stash@{1}     to view the second most recent stash in patch form). 

Note: the -p option generates a patch, as per git-diff documentation.

List the stashes:

git stash list 

Show the files in the most recent stash:

git stash show 

Show the changes of the most recent stash:

git stash show -p 

Show the changes of the named stash:

git stash show -p stash@{1} 
vote vote

87

As of JavaScript 1.8.5 you can use Object.keys(obj) to get an Array of properties defined on the object itself (the ones that return true for obj.hasOwnProperty(key)).

Object.keys(obj).forEach(function(key,index) {     // key: the name of the object key     // index: the ordinal position of the key within the object  }); 

This is better (and more readable) than using a for-in loop.

Its supported on these browsers:

  • Firefox (Gecko): 4 (2.0)
  • Chrome: 5
  • Internet Explorer: 9

See the Mozilla Developer Network Object.keys()'s reference for futher information.

vote vote

77

Girls and guys we are in 2019 and we do not have that much time for typing... So lets do this cool new fancy ECMAScript 2016:

Object.keys(obj).forEach(e => console.log(`key=${e}  value=${obj[e]}`)); 
vote vote

61

It's the for...in statement (MDN, ECMAScript spec).

You can read it as "FOR every property IN the obj object, assign each property to the PROPT variable in turn".

vote vote

60

In up-to-date implementations of ES, you can use Object.entries:

for (const [key, value] of Object.entries(obj)) { } 

or

Object.entries(obj).forEach(([key, value]) => ...) 

If you just want to iterate over the values, then use Object.values:

for (const value of Object.values(obj)) { } 

or

Object.values(obj).forEach(value => ...) 

Top 3 video Explaining git - See what's in a stash without applying it

Related QUESTION?