우분투 환경에서 Git을 시작하기 위한 방법을 정리하고자 한다.
$ sudo apt-get install git
$ git config --global user.name "name"
$ git config --global user.email "email"
순서 | 명령어 | 설명 |
---|---|---|
1 | git init | 로컬 Repository 생성 |
2 | git remote add origin [remote_repository_url] | 원격 Repository 추가 |
3 | git add [-A][local_file_path] | 상태 추적 파일 추가 |
4 | git commit [-m msg] | 상태 저장 |
5 | git push origin [branch] | 파일 업로드 |
6 | git clone [remote_repository_url][local_repository_url] | 파일 다운로드 |
7 | git pull origin [branch] | 변경 사항 업데이트(병합) |
8 | git fetch origin [branch] | 변경 사항 업데이트(병합x) |
현재 Github는 remote repository의 default branch가 main으로 되어있다.하지만, 터미널을 통해 git 명령어를 입력하는 경우 Local repository의 default branch가 master로 되어있으므로 다음 링크로 이동하여 default branch를 수정해줘야 한다.
또한 Terminal을 통해 Github 계정의 비밀번호로 사용될 토큰 설정이 필요하다. 다음 링크로 이동하여 개인 접근 토큰을 생성하여 Github 계정에 로그인한다.