git은 소스코드를 효과적으로 관리할 수 있게 해주는 소프트웨어이다. 공동 개발자들 사이에서 소스코드를 별도로 주고 받을 필요 없이, 같은 파일을 동시에 병렬 개발할 수 있도록 해준다. 개인이 브랜치를 통해 개발한 후, 본 프로그램에 합치는 방식으로 개발을 진행한다.
git config --global user.name "username"
git config --global user.email "id@mail.com"
git config --global user.name
git config --global user.email
git config --global color.ui "auto"
git config --global core.autocrlf input # for Mac and Linux
git config --global core.autocrlf true # for Windows
OS 간에 줄바꿈 문자열이 다르기 때문에 이때문에 생기는 오류를 방지해줌
git config --global init.defaultBranch main
git config --global core.editor "nano"
위는 에디터를 nano로 설정하겠다는 의미이다. VS code 등 다양한 툴을 데이터로 설정할 수 있다.
우선 repository로 지정할 디렉토리로 이동해서
git init
위 명령어를 입력하면 해당 디렉토리에 git이 연동된다. 그러면 .git이라는 디렉토리가 생기는데 여기에 프로젝트의 히스토리가 저장된다.
git status
git add filename.py
git add . # 모든 파일을 추가하고 싶을 때
git commit -m "This is ver 2. Changed matching radius 3" -> 1"."
commit 메시지는 버전 (업데이트) 내용을 기록하는 것이다.
git rm --cached <file>
git log
git diff filename.py
여기서 git diff 뒤에 HEAD~1을 붙이면 가장 최신 버전과 그 전 최신 버전의 변경 내역을 확인할 수 있다. HEAD가 가장 최신 버전이고, HEAD~1, HEAD~2, HEAD~3, ...,는 각각 그 전 최신, 그 전전 최신, 그 전전전 최신 버전을 의미한다.
** 프로젝트 루틴을 정리하자면
git init (최초 1회) → git status → 파일 작성 → git add → git commit -m → 파일 수정 → git status → git diff → git add → git commmit -m (업데이트 내용 코멘트) → ...
git checkout HEAD filename.py
https://goddaehee.tistory.com/91
https://gin-girin-grim.tistory.com/10
https://steady-coding.tistory.com/277#google_vignette
https://swcarpentry.github.io/git-novice/02-setup.html
https://velog.io/@sangyeon217/git-config
https://otzslayer.github.io/git/2021/11/12/make-vscode-default-git-editor.html