I have a huge commit and I decided to split it into two commits. So I want to make somekind of git reset
for a few files in first commit and still have my changes of theese files in git index to be able to make a next commit.
Is there a way to do it?
Asked
Active
Viewed 358 times
0

Paul
- 6,641
- 8
- 41
- 56
-
http://stackoverflow.com/a/29950959/2988730 – Mad Physicist Jul 08 '16 at 15:12
-
Did you commit the commit? Or is it just staged? Your question is unclear. – Mad Physicist Jul 08 '16 at 15:13
-
You can stage/unstage any files you want. If you already made the commit, you need to do an interactive rebase. – Mad Physicist Jul 08 '16 at 15:14
-
@MadPhysicist yes, I've already commited changes so I have a one commit with its oun hash. But I haven't pushed this commit yet so I can change everything. – Paul Jul 08 '16 at 15:15
-
Please edit your question with this information so it becomes well formed. – Mad Physicist Jul 08 '16 at 15:53
-
1Possible duplicate of [How do you undo the last commit?](http://stackoverflow.com/q/927358/2988730) – Mad Physicist Jul 08 '16 at 15:54
-
The accepted answer here is exactly what you want: http://stackoverflow.com/q/927358/2988730 – Mad Physicist Jul 08 '16 at 15:54
2 Answers
0
You can just unstage the files you want, do your commit, and then restage the files you want and do the second commit.
You could always do an interactive stage, see https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging

David Neiss
- 8,161
- 2
- 20
- 21
0
First unwind the stack one commit keeping everything in the index:
git reset --soft HEAD~
Now unstage the files you don't want until the next commit:
git reset -- next.commit.file.txt
Commit again with the same message:
git commit -c ORIG_HEAD
(Or make a new commit message)
Now add the files for the next commit:
git add next.commit.file.txt
git commit -m "next commit message"

Jeff Puckett
- 37,464
- 17
- 118
- 167