Is there a way in git to split changes in one file into two commits?

So I have a file:

...

some code here..

...

some unrelate code here..

...

and I make him the following changes:

...

some code here that needs to be changed a bunch..

...

some unrelated code here..

...

, , . , , , . , git stash , . , , git add myfile, , , . , git add?

+4
3

-p , . , .

+11

git add --patch git add --interactive .

, git gui diff, " hunk for commit" , , "stage lines for commit".

+3

git add --interactive 

.

,

git stash save 'typos'
// edit file
git commit -am 'fix'

git stash pop 

, "" (a.k.a.shelved VCS), .


Vim fugitive has much more powerful features if you are interested in using Vim for this purpose.

+2
source

All Articles