[Git] To modify a specific commit
ETCPrecautions before working
Since forced push needs to be executed, if there is a collaborator, it will proceed after consultation to prevent the Git from being twisted.
Confirm Commit to Modify
Copy the commit hash just before it to modify feat: two.
shell
git log
Enable you to modify commit
Execute the git rebase command interactively.
text
git rebase -i {commit_hash or HEAD}
git rebase --interactive {commit_hash or HEAD}
shell
git rebase --interactive 8a7b752c75de3b60c4e316de10dec5b567a0b0f5
All commits in the current (HEAD) range are displayed after the specified commit hash.
Change the pick displayed in front of the commit to be modified to edit and save it.
When the save is complete, a notice will be displayed. Commands that correct the commit are executed after the following order.
Modify Commit
Proceed with file modification.
When the modification is completed, add it to the Git preparation (staging) area with git add and commit it.
shell
git commit --amed
The commit content displayed on the screen exits as :q.
Complete the git rebase.
shell
git rebase --continue
Change confirmation
You can see that the commit hash has changed from the commit modified with git log to the latest commit. You can check how many changes have been made in the git status.
Apply
Overwrite the remote branch with a forced push.
shell
git push origin dev --force
Reference
https://docs.github.com/ko/get-started/using-git/using-git-rebase-on-the-command-line
https://homoefficio.github.io/2017/04/16/Git-과거의-특정-커밋-수정하기
https://ios-development.tistory.com/1355