Push some changes from a Git commit to a separate commit

I am in single-commit function branches (as a result of an interactive permutation that crushed all my commits).

I decided that before going to the initial state and creating a transfer request, I would like to take a subset of the changes (at the file level) in this commit and make a second commit from them, to logically separate the problems. How can i do this?

The change that I would like to break out was never in his own commit, it just got into the first commit, which I made as part of working with my function branch.

+4
source share
2 answers

Move some changes from a Git commit to a separate commit

: reset 2

, . , reset ( @hvd ):

git reset --soft HEAD^

, , , . , . , :

git reset -- path/to/file-or-dir

( ), .

, , reset , git add -p, :

git reset -- path/to/file
git add -p path/to/file

-p git add . , .

( ) .

+4

-, , . git stash, , .

git reset, "" :

$ git reset HEAD^

- , , , , .

, , git add. , , git commit.

.

.

+3

All Articles