Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging a git stash with the current head

Tags:

git

merge

github

I did a git stash on production but then others pushed more changes to the repository. So is there a way merge them both together. I can see the changes in the stash but not in the current head.

Git fsck shows

git fsck dangling tree b00308a00025bbe3eaa370b326d82dae5b9403cc dangling tree e714ea6c807bbdd039abfe8a8fb779c02403c3b3 dangling tree cc1e0f3768af3e5cb22fdfde7603f663c1812d78 dangling tree f51f1aa3298e21affb0b2ee31343f2c47df438c3 dangling tree b530b1163c677de735d82d7c11081921b35807ae dangling tree bfb862564922f45cc272daac3e1d131fd254a8ed dangling tree cdd02c02d05dfbc928c4ce9123fc4c360299395c dangling tree b851786925e57bb2d7e71badefc5171b9110ccd5 dangling tree ae5caf6ede4e4b5f9c344ac3e749aaed6bee5e96 dangling tree e56ad067c775f25d18cab3520f3f1add2731c67d dangling tree 1871498602802cbe324ed746395ac300884622ce dangling tree c0f61e31611cf5fbed159737e9f04b9b214ed663 dangling tree 7bf8bdd7e6cca37cd1929473d50d2914cc1f94c1

Thanks.

like image 625
pal4life Avatar asked Oct 27 '25 10:10

pal4life


1 Answers

One of the points of stash is that you can reapply it anywhere. You stashed away your changes, so they are stored as relative to the commit that was checked out then, but now that you've checked out a different commit, you're free to use git stash apply or git stash pop to apply the stashed changes. (pop deletes the stash once they're successfully applied; apply leaves it.)

Of course, if things have changed significantly, the stashed changes may no longer apply cleanly. Git will treat this as a merge conflict, and you can resolve it as you would any other merge conflict.

like image 101
Cascabel Avatar answered Oct 29 '25 01:10

Cascabel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!