Reputation: 48733
After further development I need to add additional changes to previous commit.
I've made a lot of changes including from IDE, that handle file renames, creating new files, etc.
So git status
shows a lot of files in staging area.
I do not want to add this files with git commit --amend --no-message
.
Can I list these files as arguments to git commit --amend --no-message
? Any other possibilities without disturbing index?
I think about stashing index - but it is complicated thing to list 40 files to ignore instead 2 files for amend....
Upvotes: 1
Views: 1817
Reputation: 48733
After experimenting I found an easy (and obvious) solution:
$ echo x >> file1
$ echo x >> file2
$ echo y >> fileZZZ
(1)$ git add .
(2)$ git ci -m fix -- file1
(3)$ git commit --no-edit --amend -- file2
At (1)
I add everything to the index. At (2)
I commit only selected files leaving others (file2
and fileZZZ
) in the index, at (3)
I add missing file2
fix leaving fileZZZ
in the index.
It is possible to work with Git almost ignoring the staging area.
Upvotes: 3
Reputation: 4031
Most IDE reflects the staging area to real Git operations. (I'm using VS Code, and it does.) So, first unstage all files with:
git reset .
Then, set your files to be staged via git add
or the IDE buttons. There should be a plus button for a file, depending on the IDE interface.
Finally, execute git commit --amend --no-message
. The semantics should be same as normal commit.
If you can't figure out how to do the things above, doing an interactive rebase to squash the commits also helps. See How to modify existing, unpushed commits?
Upvotes: 1