Git 시작하기
Git 환경 설정
- 바탕화면 git bash 실행
- git config --list
- git config user.name
- git config --global user.name
- git config user.email
- git config --global user.email
- git config 한눈에 보기
- cat ~/.gitconfig
--global 이 들어가면 컴퓨터 전역에 설정한다. 반복 수행할 필요가 없어진다.
로컬 저장소 만들기
- cd "work-dir"
- git init
- .gitignore 파일 작성
- git add --all // git add <file명> 또는 git add .
- git commit -m "first commit message"
- git remote add origin <git-remote-url>
- git push -u origin master
- git log
- git status # staging 상태 확인
(참고) GibHub RemoteURL 패턴 : https://github.com/<사용자이름>/<저장소명>.git
원격 서버에 push 할 때 충돌이 발생한 경우 6번 명령어를 git push -fu origin master로 입력합니다. -fu : 충돌이 나도 무시하고 보낸다라는 의미.
주의할 점
- 팀원이 코드를 수정하거나 커밋했을 때 서버 레파지토리를 먼저 pull로 코드를 동기화해야 합니다. 그다음에 push 해야 reject가 발생하지 않습니다.
git clone & pull 하는 방법
GitHub에 만든 repo와 클론 하기
- git clone "github-remote-url"
git pull : 서버의 최신 소스를 다운로드하기
- git pull
- touch aaa.txt
- git add --all
- git commit -am “message”
- git push
(참고: 서버와 연결된 repo 끊기): git remote rm origin
'SERVER > Git' 카테고리의 다른 글
Git 사용자 인증 오류 (0) | 2021.09.28 |
---|---|
# 4 - Git 실무 - with VSCode (0) | 2021.09.24 |
# 3 - Git Branch / merge (0) | 2021.09.21 |
[Git] Reset & Revert / conflict & merge (0) | 2021.09.20 |
[Git] .gitignore 파일 (0) | 2021.09.19 |