# 한글 파일명 깨짐 방지git config --global core.quotepath false# 한글 커밋 메시지 지원git config --global i18n.logoutputencoding utf-8git config --global i18n.commitencoding utf-8
저장소 초기화
새 저장소 생성
# 현재 디렉토리를 Git 저장소로 초기화git init# 새 디렉토리 생성하면서 초기화git init my-projectcd my-project# bare 저장소 생성 (서버용)git init --bare my-repo.git
원격 저장소 클론
# 기본 클론git clone https://github.com/user/repo.git# 다른 이름의 폴더로 클론git clone https://github.com/user/repo.git my-folder# 특정 브랜치만 클론git clone -b feature-branch https://github.com/user/repo.git# 얕은 클론 (최근 커밋만, 빠른 다운로드)git clone --depth 1 https://github.com/user/repo.git# 서브모듈까지 함께 클론git clone --recursive https://github.com/user/repo.git
원격 저장소 연결
원격 저장소 추가
# origin 원격 저장소 추가git remote add origin https://github.com/user/repo.git# upstream 원격 저장소 추가 (포크한 경우)git remote add upstream https://github.com/original/repo.git# 원격 저장소 목록 확인git remote -v
원격 저장소 관리
# 원격 저장소 URL 변경git remote set-url origin https://github.com/user/new-repo.git# 원격 저장소 이름 변경git remote rename origin new-origin# 원격 저장소 제거git remote remove upstream
초기 커밋
첫 번째 커밋 만들기
# README 파일 생성echo "# My Project" >> README.md# .gitignore 파일 생성curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore# 파일 추가 및 커밋git add .git commit -m "Initial commit"# 원격 저장소에 푸시git push -u origin main
기본 브랜치 설정
# main을 기본 브랜치로 설정git config --global init.defaultBranch main# 현재 브랜치 이름 변경git branch -M main# 원격의 기본 브랜치 확인git remote show origin
유용한 초기 설정
별칭 설정
# 자주 사용하는 명령어 단축키git config --global alias.st statusgit config --global alias.co checkoutgit config --global alias.br branchgit config --global alias.ci commitgit config --global alias.unstage 'reset HEAD --'
보안 설정
# HTTPS 대신 SSH 사용 (권장)git config --global url."git@github.com:".insteadOf "https://github.com/"# 자격 증명 저장 (신중하게 사용)git config --global credential.helper store
성능 설정
# 자동 가비지 컬렉션 설정git config --global gc.auto 256# 대용량 파일 처리 개선git config --global core.preloadindex truegit config --global core.fscache true