티스토리 뷰

GitHub

(macOS) git fetch vs pull

jinozpersona 2022. 2. 10. 01:06

INTRO

git fetch와 pull 차이

 

1. git fetch : 별도 병합(merge) 필요

git:([branch])$ git fetch origin

원격저장소 commit 파일을 로컬저장소로 가져온다.

원격저장소와 로컬저장소의 변경된 내용을 확인할 수 있다.(origin/[branch], branch는 master, main, ...)

git:([branch]$ git log --decorate --all --oneline

변경된 내용 확인 후 merge하면 git pull과 동일해진다.

git:([branch])$ git merge origin/[branch]

 

2. git pull : git fetch와 git mergy를 실행한 것과 동일

git:([branch])$ git pull origin [branch]

원격저장소 commit 파일을 로컬저장소로 모두 가져온다.

원격저장소 commit 파일이 update된 내용이고 로컬저장소 파일이 최신 버전이 아닐 때(물론 비어있을 때도..) 사용한다.

원격저장소와 로컬저장소의 변경된 내용을 확인할 수 없다.

 

 

git pull 실행하기

git:(main)$ git pull origin main

remote: Enumerating objects: 192, done.
remote: Counting objects: 100% (192/192), done.
remote: Compressing objects: 100% (167/167), done.
remote: Total 192 (delta 26), reused 181 (delta 18), pack-reused 0
오브젝트를 받는 중: 100% (192/192), 539.02 KiB | 475.00 KiB/s, 완료.
델타를 알아내는 중: 100% (26/26), 완료.
https://github.com/jinozpersona/jinozpersona.github.io URL에서
 * branch            main       -> FETCH_HEAD
 * [새로운 브랜치]   main       -> origin/main
error: 병합 때문에 추적하지 않는 다음 작업 폴더의 파일을 덮어씁니다:
.editorconfig
.gitattributes
.github/workflows/pages-deploy.yml
.gitignore
.nojekyll
병합하기 전에 이 파일을 옮기거나 제거하십시오.
중지함

 

# 참고 : error 발생 시 위에 지정된 파일을 백업하거나 지우고 pull 재실행

git:(main)$ git pull origin main

https://github.com/jinozpersona/jinozpersona.github.io URL에서
 * branch            main       -> FETCH_HEAD

 

 

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함