-
[AWS] 서버에서 git 연동 및 사용법개발 프로세스/Cloud 2020. 9. 27. 15:55
<서버와 github repository와 연동>
1. 서버에 git을 설치한다
yum install -y git
2. git 초기화
git init
3. 서버와 github repository에 접속한다
git remote add origin [repository url]
git remote add origin https://github.com/surimyoo/carbon_diet.git
4. 서버와 default branch를 연동한다
git pull origin main
github repository에서 defalut branch 이름이 main인지 master 등에 따라 명령어 입력. 원래 github default branch는 master로 자동 생성되었으나, 최근 master 라는 단어가 노예제를 연상시킨다는 이유로 main으로 변경되었다고 한다.
default branch의 이름을 확인한다 <gtignore 설정>
vim .gitignore
https://www.toptal.com/developers/gitignore
gitignore.io
Create useful .gitignore files for your project
www.toptal.com
자신이 사용하는 운영체제나, 프레임워크, 파이썬언어 등을 검색하여 깃에 올릴 때 무시할 파일 목록들을 'vim .gitignore'에 복붙한다. 해당 프로젝트에서는 django를 검색하여 gitignore 목록을 설정하였다.
<git에 파일 올리기>
1. 상태확인
git status
git에 올라가지 않은 파일 목록들이 뜬다 2. git에 올릴 파일 목록에 "practice_python"파일을 리스트업
git add practice_python
2-1. git에 올릴 파일 목록에 전체 추가
git add .
목록을 추가한 후 'git status' 명령어를 통해 상태를 확인했다 2-2. 파일 목록 초기화
git reset HEAD~0
3. 올릴 목록들 이름 정하기(커밋하기)
git commit -m "first commit"
4. git 커밋 기록 확인
git log
5. main 브랜치에 파일 목록들 최종 업로드
git push origin main
<서버 파일 삭제>
rm practice_python
서버에 파일 삭제
git rm practice_python
git에 삭제할 파일 목록에 "practice_python"파일을 리스트업
git commit -m "first commit delete"
git push origin master
'개발 프로세스 > Cloud' 카테고리의 다른 글
[AWS] EC2 인스턴트 생성 (0) 2021.08.06 [Google Cloud] Google Vision API 사용기 (0) 2021.05.06 [AWS] 서버에 Python-MySQL 연동하기 (0) 2020.09.24 [AWS] 서버에 django 설치하기 / django 프로젝트 생성 (0) 2020.09.24 [AWS] MySQL 계정 추가 및 접근권한 부여 (0) 2020.09.06