Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I 'git stash' changes for multiple commits?

Tags:

git

git-stash

I have five files that have been changed: 1-3 need to be in a single commit, while 4 and 5 need to be different commits entirely, so I need 3 separate commits in all. How do I use git stash to accomplish the following:

commit1:
  file1
  file2
  file3
commit2:
  file4
commit3:
  file5

without losing any of my changes? Thanks!

like image 692
DrStrangepork Avatar asked Nov 03 '25 00:11

DrStrangepork


1 Answers

If I'm reading your question correctly, you don't need to use git stash at all...

You could just add them and commit them separately:

git add file1 file2 file3
git commit -m "first message"
git add file4
git commit -m "second message"
git add file5
git commit -m "third message"
like image 79
CDub Avatar answered Nov 05 '25 15:11

CDub



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!