0
Using the VSCODE + GIT, made several changes in a same file, on a necessary implementation.
In order for these implementations to be made, it was first necessary to adjust/correct a pre-existing code (already committed at another time), and then to apply the implementation. However, I did it all at once, and when I went to generate the implementation commit, I noticed that I could split into several commits to get more detailed in small commits the changes/fixes made and other with the implementation.
For example, imagining this is the code below in the same file:
// parte do código adaptado/ajustado independente da implementação
function corrigindoMetodoAnterior(params)
{
// executando alguma ação pertinente
// ...
}
// referente a uma implementação feita
function implementandoNovoMetodo(params)
{
// executando alguma ação pertinente
// ...
}
// conteúdo temporário
function naoCommitarEste(params)
{
// informações de teste que não é pra commitar
// ...
}
Supposing that all these acima lines are as "edited", being that:
- the first function
corrigindoMetodoAnterior
existed but has undergone changes; - the second function
implementandoNovoMetodo
was added because it did not exist; - the third function
naoCommitarEste
is a developing method that will not enter any commit;
So, every function of this, I want it to be in separate commits:
- "Adjustments of the 'correcting' function All Material for better performance"
- "Adding new 'implementationNovoMetodo' function to meet new demand"
And don’t have in any commit above the 'naoCommitarThis'
There is how to do this graphically straight on VSCODE using the Source Control of GIT, or only by command line?
Equivalent to what I want with a command line would be:
$ git add -p
All file changes will be displayed, with an interactive menu with some options.
Choosing the option s
(split), it will present each amendment separately.
(...)
Stage this hunk [y,n,q,a,d,s,e,?]? s
So just give y
(yes) or n
(no) to add or not to commit.
(...)
Stage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? y / n