728x90
Undoing commit and push
Troubleshoting done by
Paragraph edited and translated by
See JS debugging tutorial in YouTube
During this YouTube tutorial, I had encountered one github troubleshooting. A commit for image file had been placed in javascript code, not the original image one. Undoing a git push I made had always been a unwelcome guest so I decided to face it and figure out this time.
How to undo git add
- git reset HEAD [file name]
- check result with git status
How to undo git commit
- git log
- git reset --soft HEAD~1
In the below example, do git reset --soft HEAD~2 to undo the hightlighted commit fb43dd4.
- HEAD~1 : one step before HEAD
- HEAD~2 : two steps before HEAD
- e.g. git reset --soft HEAD~2 : undo two commits(HEAD, HEAD~1)
How to undo git push
- git log
- git revert [commit hash]
- git push [the repo where the misled commit was pushed] main
By following above instruction, the expected result is as follows :
- Message that say [Revert "your mis-typed commit"]
- Github deleting the file you added with the wrong commit
- The file being deleted in your local
Changing directory name
- git mv (current name) (change name)
- git add
- git commit
- git push
Your folder name will be changed and the commits of the files belonging to the folder will be affected, meaning previous commits overwritten.
728x90
'창고 3 > [Dev] My Readme' 카테고리의 다른 글
몽고 DB 기초 2 (0) | 2022.01.05 |
---|---|
몽고 DB 기초 1 (0) | 2022.01.04 |
git pull request 단계별 연습하기 (0) | 2022.01.03 |
운영체제 기초 2 (0) | 2021.12.27 |
운영체제 기초 1 (0) | 2021.12.24 |
댓글