notebook/IT/Git/Rewrite_History.md

48 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2020-11-27 17:40:42 +00:00
# Rewrite Git History
## Changing the Last Commit
If you want to modify your last commit message:
`git commit --amend`
## Rewrite multiple Commit
for that you need to use rebase in interactive mode like this:
` git rebase -i HEAD^3 `
this will open an editor wit list of commit you need to modiy this with needed action to do
### Reordering Commit
ON this editor you can invert line to change commit order, git will reaply commit in wew order
### Squash & fixup commit
**Squash** option will merge will merge xommit with the previous and ad commit message in the new commit message
**Fixup** do same thing put forgot commit message
### Splitting a Commit
you can do that with **edit** command
git rebase will stop after apply commit where you hae put edit
ad this moment you can process to a Head reset and commit when you want to add commit modification like ewample below
```sh
git reset HEAD^
git add README
git commit -m 'Update README formatting'
git add lib/simplegit.rb
git commit -m 'Add blame'
git rebase --continue
```
### delete
**drop** will delete comite rebase will not apply modification during processing
2021-04-20 21:13:14 +00:00
to use by example if you have done a modifcation and a revert