I went through a similar problem and the solution that I will go over now has answered me perfectly. I will do as a step-by-step minute to also help other people who at least have the git basics, which is to create, delete, update and toggle branch , " commitar "and others.
At first I created a new branch to not apply commands that might make the use of branch
First update the master, afterwards, update your *branch*-antiga
from the master and also, from the master, create a *branch*-nova
. The goal is to commit commit by commit from *branch*-antiga
to *branch*-nova
;
In *branch*-antiga
use the command: git log --author="Fulano da Silva" --name-only
. What does this command do? The git-log shows the commit logs and parameters --author=<pattern>
applies a " pattern "in the commit header. In this case you will get the commit's by name and --name-only
shows the "path / names" of the changed files. Here is an example of the complete code output in the terminal:
commit 94d580b6c9480ac23908799681bebc947a3e760f
Author: Djalma Manfrin <[email protected]>
Date: Fri Jan 6 11:12:03 2017 -0200
nome do commit
caminho/do/arquivo/arquivo_1.php
caminho/do/arquivo/arquivo_2.php
caminho/do/arquivo/arquivo_3.php
Note: Realize that commit is in order. From the latest to the oldest. This order is important for the next step. We will commit commit from commit from the oldest to the newest.
For ease, split the terminal screen into two screens. On a screen, run the command from step 2 to list the commit's and the other, change to *branch*-nova
and apply the command: git cherry-pick 68e4bde4a83910cb0b4a8df82078e70131ce9280
. What does this command do? The git-cherry-pick applies changes to the current branch of a < in> commit . Change the hash as explained in step 2, from the oldest to the newest.
Note: Normally running the git cherry-pick
command does not generate conflict, but if it does, you will have to solve it in the arm by analyzing the code that you want to "commit." Each conflict is a particular case and if it happens comment or open a new question in Stack so we can help you. If you do not need to move commit , skip to step 5
As I had informed the question and how it was also my case. In a single commit there were minor and major changes to the system as a whole. So, in that case I had to apply the command: git reset HEAD^1
. What does this command do? The git-reset resets the current HEAD to the specified state passed as parameters. In our case the specified state will be HEAD^1
.
Note: In a rough way, the git-reset
command is the opposite of git add
. Our specification HEAD^1
means that we want to change / return the HEAD a commit backwards. This commit is not lost. It comes back as changes that can be "committed." This will allow you to make changes to a commit and "commit it in parts". In our case, it will be possible to separate by commit the low and large complexity. Finally, commit changes as needed.
After finishing the current commit , go back to step 3. This was the way I found to solve my problem. I hope it helps you.