| ... | ... | @@ -104,7 +104,7 @@ Users are urged to provide as much context as possible in their commits. |
|
|
|
|
|
|
|
A commit should be atomic, meaning that 1 commit must contains changes that :
|
|
|
|
|
|
|
|
1. Work.
|
|
|
|
1. Are functionnal. If they are currently not, its ok, everybody does "checkpoints commits" during the development process. But final commits that will be merged in dev/main need to be functionnal. To modify commits, head to \[git rebase --interactive\]()
|
|
|
|
2. Can be grouped under 1 common designations (the commit message).
|
|
|
|
3. This designation is the shortest common denominator.
|
|
|
|
|
| ... | ... | @@ -322,11 +322,11 @@ git rebase -i <hash> |
|
|
|
|
|
|
|
Here is my current history.
|
|
|
|
|
|
|
|
{width=734 height=116}
|
|
|
|
{width="734" height="116"}
|
|
|
|
|
|
|
|
We can see issues here :
|
|
|
|
|
|
|
|
1. There are 3 commits about resize : They ould be aggregated in 1. I created 1 "new feature" & 2 "refactors" commits which served as "checkpoints" during my development. But actually a commit informing of a refactor would only be valuable to inform users/devs of a breaking change. In this case, I am the only one who have worked on it as of now. So no need for 3 commits
|
|
|
|
1. There are 3 commits about resize : They ould be aggregated in 1. I created 1 "new feature" & 2 "refactors" commits which served as "checkpoints" during my development. But actually a commit informing of a refactor would only be valuable to inform users/devs of a breaking change. In this case, I am the only one who have worked on it as of now. So no need for 3 commits
|
|
|
|
2. The commit order is not what I would like it to be.
|
|
|
|
3. `18630dc` message is not the right one.
|
|
|
|
|
| ... | ... | @@ -336,9 +336,9 @@ All of that can be done with `git rebase --interactive`. I just need to select t |
|
|
|
git rebase -i f9d74d9
|
|
|
|
```
|
|
|
|
|
|
|
|
This will open your default text editor (configured with `$EDITOR`) with this inside :
|
|
|
|
This will open your default text editor (configured with `$EDITOR`) with this inside :
|
|
|
|
|
|
|
|
{width=600 height=490}
|
|
|
|
{width="600" height="490"}
|
|
|
|
|
|
|
|
We can see 2 parts :
|
|
|
|
|
| ... | ... | @@ -352,26 +352,26 @@ Here we want to : |
|
|
|
|
|
|
|
1. Squash (/merge) all commits about resize in 1 commit.
|
|
|
|
2. Reorder commits.
|
|
|
|
3. Reword `18630dc`
|
|
|
|
3. Reword `18630dc`
|
|
|
|
|
|
|
|
I can do that here by modifying the text file like follows (only showing the part that actually changes) :
|
|
|
|
I can do that here by modifying the text file like follows (only showing the part that actually changes) :
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
What I have done :
|
|
|
|
|
|
|
|
1. Re-ordered the commits
|
|
|
|
2. Put replaced `squash` by `pick` in front of the commits I wanted to merge with the previous one.
|
|
|
|
2. Put replaced `squash` by `pick` in front of the commits I wanted to merge with the previous one.
|
|
|
|
3. Put `reword` instead of `pick` in front of the repo I wanted to rename.
|
|
|
|
|
|
|
|
Now I will save and quit my editor and this will open new editors to choose the new names of the commits that will be created.
|
|
|
|
|
|
|
|
1. For reword :
|
|
|
|
|
|
|
|
{width=614 height=269}
|
|
|
|
2. For the squashed commits (here I will remove the last 2 commits messages as they are useless)
|
|
|
|
{width="614" height="269"}
|
|
|
|
2. For the squashed commits (here I will remove the last 2 commits messages as they are useless)
|
|
|
|
|
|
|
|
{width=575 height=521}
|
|
|
|
{width="575" height="521"}
|
|
|
|
|
|
|
|
Once every thing is done, here is my new git history all cleaned up :
|
|
|
|
|
| ... | ... | @@ -383,7 +383,7 @@ Once every thing is done, here is my new git history all cleaned up : |
|
|
|
|
|
|
|
Since you edit the history of the repository, if you modify commits that were previously pushed, you will need to FORCE PUSH afterward. If you screwed up anything and force push, you will ERASE commits history : THIS CAN HAVE HORRENDOUS CONSEQUENCES. If you are not sure of what you are doing , please call someone more competent than you.
|
|
|
|
|
|
|
|
:warning: **rebase after merge = conflicts**
|
|
|
|
:warning: **rebase after merge = conflicts**
|
|
|
|
|
|
|
|
> Lets say you want to merge branch A & B, from branch A, you will call `git merge B`. You history will then look smthg like
|
|
|
|
>
|
| ... | ... | |