[Github] 잔디 누락 복구하기

우롱차·2022년 9월 28일
1

Github

목록 보기
1/1

참고: https://wellbell.tistory.com/43

명령어

  1. local 환경의 user.email, user.name 확인
	git config --list
  1. local 환경의 git 전체의 user.email, user.name 수정
	git config --global user.email "내 이메일 주소"
	git config --global user.name "내 닉네임"
  1. commit 기록 확인하기 (해쉬코드 찾기)
	git log --pretty=format:"%h = %an , %ar : %s" --graph
  1. 해쉬코드로 rebase 하기 (첫 commit 기록의 해쉬코드를 입력하는 것이 좋다.)
	git rebase -i --rebase-merges 해쉬코드
  1. vim 창이 뜨면 i(insert)를 입력하고 누락된 commit 기록을 pick에서 edit로 수정해준다.
    수정 후 esc를 누르고 :wq! 를 입력하여 창 나오기

  2. commit 하기 - 이름: user.name, 이메일: user.email

	git commit --amend --author="본인 이름 <본인 이메일>"
    
    ex) git commit --amend --author="wooryung <wooryung1004@naver.com>"
  1. vim 창이 떴을 때 commit 내용을 수정하고 싶다면 i 입력 후 수정, esc → :wq!
    수정할 내용이 없다면 esc → :wq!

  2. 다음 대상을 commit 하기 위해

	git rebase --continue
  1. commit 할 개수 만큼 6~8 반복

  2. commit이 모두 완료되면 강제 push

	git push origin +브랜치이름
    
    ex) git push origin +master
  1. local의 default branch와 git의 default branch가 같은지 확인 후 다르다면 바꿔줘야 한다.

    참고: https://shinye0213.tistory.com/173

profile
아직 따끈따끈합니다🍵

2개의 댓글

comment-user-thumbnail
2023년 5월 11일

제가 원래 벨로그 댓글 거의 안 남기는데 이 글 덕분에 사라진 잔디를 복구해서,,,, 감동받았습니다 감사합니다!

1개의 답글