Git: 깃허브 원격 저장소 커밋 모두 지우기

지니·2022년 9월 10일
0

깃허브 관리를 하다가 원격저장소 커밋을 모두 지워야 하는 상황이 생겼다!
아래 명령어를 실행하면 마지막 커밋까지 지워지는 동시에 새로 만든 커밋을 push 할 수 있었다. 😁

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A

# Commit the changes:
git commit -am "Initial commit"

# Delete the old branch:
git branch -D master

# Rename the temporary branch to master:
git branch -m master

# Finally, force update to our repository:
git push -f origin master
profile
오늘도 호기심을 발휘한다!

0개의 댓글