본문 바로가기
창고 3/[Dev] My Readme

git commit 취소하는 법, git push 취소하는 법, git 폴더명 변경하기

by 부엉이의 정보 창고 2022. 1. 4.
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

  1. git reset HEAD [file name]
  2. check result with git status

How to undo git commit

  1. git log
  2. 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

  1. git log
  2. git revert [commit hash]
  3. 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

  1. git mv (current name) (change name)
  2. git add
  3. git commit
  4. 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

댓글


loading