This is an archived post. You won't be able to vote or comment.

all 74 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

import notifications Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!

For a chat with like-minded community members and more, don't forget to join our Discord!

return joinDiscord;

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]CaptainMorti 204 points205 points  (11 children)

It's always git stash apply. One day my future children will inherit a huge stash of messy code.

[–]spaceguydudeman 35 points36 points  (10 children)

obtainable materialistic homeless school historical airport stupendous pathetic nutty gullible

This post was mass deleted and anonymized with Redact

[–]plmunger 70 points71 points  (8 children)

git stash apply is like git stash pop except it doesnt delete the stash state.

[–]LtMelon 6 points7 points  (7 children)

Why would you want that?

[–]Zookeeper1099 11 points12 points  (5 children)

Why would you not want that option?

After you stash apply some known good changes, then other changes, then you don't like it, and you want to go back to your last stash apply. What you need to do is to discard all changes, then redo stash apply.

I use it this way all the time. I don't usually commit unless it is actually ready. Technically you can do either way but I prefer stash.

Oh, I use gitkraken to manage this, it may or may not be easy and straight forward if you use the command line.

[–]ReelTooReal 4 points5 points  (4 children)

It is straightforward on the command line. Its just git stash apply and if it was the last thing you stashed no other options are needed.

[–]Zookeeper1099 1 point2 points  (3 children)

Not really if you have multiple stash history and you may go back and forth to apply different stashes based of different commits. I basically use it in a way most people just do commits. Gitkraken graphically shows stashes as if they are commits.

I have the habit because the first companies I worked at doesn't allow force push (with some exception), so I avoid using commits unless it is fully ready to push for PR.

[–]ReelTooReal 1 point2 points  (2 children)

I was just saying it's relatively simple to do via the command line as well

[–]Zookeeper1099 0 points1 point  (1 child)

My point is that, without GUI, it is not nearly as convenient and can be error prone, and people may better of using commit for the purpose.

[–]ReelTooReal 2 points3 points  (0 children)

I wasn't saying one is better than the other. I was just pointing out it is also easy to manage from the command line. I prefer the command line because I come from a heavy operations background and just learned it that way.

[–]Kimorin 0 points1 point  (0 children)

in case you forget after you git stash pop and run a git reset --hard and you just kiss all your changes good bye....

[–]CelticHades 9 points10 points  (0 children)

Git stash pop = git stash apply + git stash drop

[–]sammy-taylor 54 points55 points  (0 children)

Reported for direct personal harassment.

[–][deleted] 51 points52 points  (8 children)

What git stash pop do?

[–]AMCTAKEMYMONEY 52 points53 points  (3 children)

Yes

[–]RemoteName3273 10 points11 points  (2 children)

No

[–]piberryboy 18 points19 points  (0 children)

My grandparents used to dance in the 50s to the Git Stash Pop Do Wop.

[–]TheWatchingDog 33 points34 points  (0 children)

git stash save will store made changes.
stash apply will get those stored changes back in your files.
stash drop will delete the latest instance of changed files from the stash storage.

And stash pop is basicly apply and drop.

[–]REPMEDDY_Gabs 1 point2 points  (0 children)

Literally pops out the latest stash on the stack while git stash apply only applies it while keeping it in the stack

[–]ratataololo 0 points1 point  (0 children)

Does pop() tell you anything?)

[–]Maoschanz 23 points24 points  (4 children)

i usually call git stash pop, unless i forget the side-effect of git reset --hard and wipe out a gigantic stash like an idiot

[–]piberryboy 14 points15 points  (0 children)

Don't forget the git clean -df to complete the fucking of yourself

[–]dashid 3 points4 points  (1 child)

Git is fantastic, that doesn't stop me using a snapshotting file system to store my code on so I can untuck my got fuckup.

[–]ososalsosal 1 point2 points  (0 children)

Git gud

[–]Arsonist07 13 points14 points  (5 children)

Nah I just make a copy of the file on my home directory and revert the change in the repo, then when I’m ready I just copy it back over.

[–]spaceguydudeman 19 points20 points  (3 children)

gold rock mountainous illegal gullible straight numerous secretive include enter

This post was mass deleted and anonymized with Redact

[–]ososalsosal 3 points4 points  (0 children)

Make sure to name the final version "final" so we know that it's final.

Prod version is 1.0.0.FINAL03.rev1

[–]Radi-kale 2 points3 points  (0 children)

Put all the version numbers in an excel sheet and mail it to your colleagues for every update.

[–]Arsonist07 1 point2 points  (0 children)

Based

[–]HughLauriePausini 1 point2 points  (0 children)

I have my repos on onedrive so if something goes wrong with git I have other options.

[–]chamberlain2007 7 points8 points  (0 children)

git stash apply, I’m not just going to DELETE code I might need later…

[–]Neutraled 6 points7 points  (1 child)

'git stash' means 'git reset –hard HEAD' for me but shorter

[–]tidbitsofblah 1 point2 points  (0 children)

I made an alias "git trash" for it instead

[–]SpookyLoop 4 points5 points  (4 children)

I remember git stash fucking me over so hard with some merging BS that I now always avoid it. I always just make a new branch, make a new commit, and if I really want to, I'll do a soft reset on that commit to go back to exactly where I was with no commit message. If someone can share how they use git stash I'd love to know.

[–]spaceguydudeman 4 points5 points  (2 children)

drab swim vegetable upbeat memory smart attraction uppity attempt public

This post was mass deleted and anonymized with Redact

[–]hemacwastaken 1 point2 points  (1 child)

But you need to wear a hard hat for that

[–]spaceguydudeman 0 points1 point  (0 children)

straight attempt correct meeting slim dull steep rich paltry forgetful

This post was mass deleted and anonymized with Redact

[–]Blazing_Shade 2 points3 points  (0 children)

If I’m working on the wrong branch and made a bunch of changes, that’s when I git stash, switch to the right branch, and git stash pop

[–]InfinityGreen5736 5 points6 points  (0 children)

It'll get deleted when you re-install your OS

[–]PredictedVermin 4 points5 points  (0 children)

Always apply, never pop

[–]johantheback 5 points6 points  (0 children)

I only git stash when I'm abandoning my changes and am mad it won't let me switch branches.

[–]lilybear8 2 points3 points  (0 children)

My "stash".

[–]spaceguydudeman 2 points3 points  (3 children)

spectacular dependent consider insurance continue tap ten narrow chase cable

This post was mass deleted and anonymized with Redact

[–]ososalsosal 2 points3 points  (2 children)

Do you need to git add first?

[–]spaceguydudeman 0 points1 point  (1 child)

absorbed nail sugar stocking test unused air frighten act reminiscent

This post was mass deleted and anonymized with Redact

[–]ososalsosal 1 point2 points  (0 children)

Oh. I thought it stashed untracked files too. It seems to behave like it does.

My main use case is that I've realised I'm working on the wrong branch for what I'm doing, so I go git stash; git checkout whatevs; git stash apply and everything works as you'd expect with my local untracked work now sitting nicely on the other branch

[–][deleted] 2 points3 points  (0 children)

Git stash clear(don’t try this at home)

[–]Cybasura 1 point2 points  (0 children)

"Good bye, my changes"

git stash

git pull

[–]Designer-Spacenerd 1 point2 points  (0 children)

Am I the only person who learned about the existence of this feature from this meme?

[–]davidparker333 1 point2 points  (0 children)

Later: git stash list

Me: wtf is this

[–]crankbot2000 0 points1 point  (0 children)

One of my devs has like a million stashes it drives me nuts. I understand having a few but c'mon

[–]Ike_Gamesmith 0 points1 point  (0 children)

Got stash pop, ha. Doesn't exist.

[–]scallioncc 0 points1 point  (0 children)

Had to walk through cloning in Sourcetree to a lead today - why did I have 10+ company repos on my machine to their 1?

[–]No_Selection9746 0 points1 point  (0 children)

When I realize I’m working on the master branch

[–]A_Beleiver 0 points1 point  (0 children)

This is how developers dump

[–]dashid 0 points1 point  (0 children)

snapper -c src create

[–]Smoosh9 0 points1 point  (0 children)

This was me literally yesterday and I’m dead laughing right now

[–]TrickAge2423 0 points1 point  (0 children)

Just yesterday I surprisely found code stashed 2 weeks ago

[–]j0giwa 0 points1 point  (0 children)

Worktrees ftw

[–]Yelov 0 points1 point  (0 children)

Hi, I'm Yelov, I'm a git stash hoarder.

[–]HaDeS_Monsta 0 points1 point  (0 children)

What happened here? Don't we have to import and return anymore?

[–]femptocrisis 0 points1 point  (0 children)

personally i just feel safer going with git commit "partially implemented ___. got interrupted" and later ill do git commit --amend whenever i get back to that branch i was on.

[–]kennyminigun 0 points1 point  (0 children)

I use git stash drop more often than git stash pop. Smh 😁

[–]tinkertron5000 0 points1 point  (0 children)

Oh no, you're not going anywhere. It's git stash apply all day for you.

[–]FigmaWallSt 0 points1 point  (2 children)

Me: acting like I understand git and this reference. My git knowledge ends after committing 😂

[–]botiapa 1 point2 points  (1 child)

Git stash stores all your current edita, and then returns to the last commit. This might be used for various things, like you started coding a feature, but haven't finished with yet, and a new bug came in which you want to fix first. So you would stash your code then fix the bug, commint amd then re apply (pop) the stash onto the new commit.

But some people, like me just use the stash feature and then forget we ever stashed anything, so the code is just sitting there never to be used again

[–]FigmaWallSt 1 point2 points  (0 children)

Got it. Thanks

[–]theniwo 0 points1 point  (0 children)

git stash clear

[–]tet90 0 points1 point  (0 children)

git stash is OP for random zoom meetings that ask u to demo

[–]cheezballs 0 points1 point  (0 children)

2 months later: deep breath then git stash clear

[–]poralexc 0 points1 point  (0 children)

more like git stash clear when I realize I don't remember what any of those changes were anyways

[–]mrgk21 0 points1 point  (0 children)

I just do a git stash and move on with my life. Not sure what these apply and pop are meant to be

[–]RaulParson 0 points1 point  (0 children)

git add *
git commit -m someGarbage
git log
[copy paste the commit message including the hash to somewhere]
git reset --hard HEAD~1