본문 바로가기
TIL/Git

Git | revert

by 홍차23 2020. 10. 15.

git push 를 했더니

error: failed to push some refs to

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

= 현재 로컬 파일과 원격저장소 파일의 불일치 때문에 나오는 에러

 

1) git pull //원격저장소에 있는 파일을 받아온다.

2) 두개가 다르기 때문에 충돌이 발생한다. 

3) git revert 'commit번호' //원격저장소에 있던 파일을 버리고 현재 로컬에 있던 파일을 선택하기 위해서, 바로 직전 커밋을 revert 한다.

4) git push

 

참고: revert 와 reset 차이

https://www.devpools.kr/2017/02/05/%EC%B4%88%EB%B3%B4%EC%9A%A9-git-%EB%90%98%EB%8F%8C%EB%A6%AC%EA%B8%B0-reset-revert/

'TIL > Git' 카테고리의 다른 글

Git | error: failed to push some refs to  (0) 2020.12.11
Git | branch conflict 해결하기  (0) 2020.11.23
Git | fatal: No such remote  (0) 2020.10.15
Git | fatal: remote origin already exists  (0) 2020.10.15

댓글