본문 바로가기
내가 보려고 정리하는/GIT

[Git] 초기 설정/ pull & push 관련 정리

by alasdkfm 2022. 9. 8.

git 초기설정(유저등록)

git config --global user.name <이름>
git config --global user.email <깃헙이메일>
#깃헙 이메일과 위의 이메일이 서로 다를경우, github contribution(잔디깔기) 반영되지 않음

원격 저장소 등록

git remote add origin <주소>

#주소확인
git remote -v

원격 저장소 주소 수정

git remote set-url origin <저장소 주소>

원격 저장소 복제하기

  • github 에서 해당 device로 초기에 파일을 받아오는 경우에만 사용 (.git파일 없는 경우)
git init 
git clone <원격저장소 주소>

pull : 원격 저장소에서 파일 받아오기

git pull origin main

push : 로컬 저장소에 변경된 내용 원격 저장소에 반영하기

git push -u origin <branch name>

강제로 push하는 방법

  • 옵션 -f / + 쓰기
git push origin <branch name> -f
#혹은
git push origin +<branch name> 

#ex. 
git push origin master -f
git push origin +master

현재 stage 상태 확인

git status

변경이력 확인

git log

add: 변경사항 staged로 올리기

git add <파일명>
  • (option) : 점(.) 은 '전부'를 의미

한번에 add & commit 하기

git commit -am <커밋메세지>
  • git 문서에 따르면 'git commit -a' automatically stage all tracked, modified files before the commit
  • git commit -am = git commit -a + git commit -m 이므로,
  • 모든 변경된 파일을 한번에 업로드하고 이에 대한 커밋메세지를 작성하고 싶을 때 사용하면 좋을 것 같다.

한글깨짐 문제 해결방법

git config --global core.quotepath false

(한글깨짐 해결방법 참고: https://zlzzlzz2l.tistory.com/50)

'내가 보려고 정리하는 > GIT' 카테고리의 다른 글

[Git] 에러 모음  (0) 2022.11.25
[Git] 커밋 날짜 수정하기  (0) 2022.11.13
[Git] COMMIT 관련 명령어 정리  (0) 2022.11.13
[Git] Branch 관련 정리  (0) 2022.11.13