git 개념 및 명령어 정리
개인 개발을 넘어, 공동 개발에서 효율적인 코드 형상 관리를 하기 위함.
(1) Working Directory (Local)
: 개인 코드 작성
(2) Staging 영역
: git add 를 통해서 수정된 코드를 올리는 영역
(3) Repository
: git commit 을 통해서 최종 수정본을 제출
1) 우선 현재 폴더를 Git 로컬 저장소로 설정
<in>
git init
<out>
Reinitialized existing Git repository in 경로
2) 원격 저장소 추가
<in>
git remote add origin "저장할 github 주소"
필자의 경우 git clone 경로를 사용해서 가져오고 연동을 미리 시켜놨다.(건너띔)
3) 변경된 파일 저장
<in>
git add -A
add는 수정된 파일 모두 추가 -A 말고 파일명으로 업로드 가능, 이외에도 push 등 있음.
4) 상태확인(복사한 파일이 변경사항이 있는지 확인)
<in>
git status
<out>
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: .report.json
modified: chinook.db
modified: src/Part_1.py
modified: src/Part_2.py
modified: src/Part_3.py
5) 커밋달기(뭐가 변경된건지 설명)
<in>
git commit
<out>
[main 961c8ab] 1차 제출
5 files changed, 101 insertions(+), 39 deletions(-)
create mode 100644 .report.json
rewrite src/Part_1.py (73%)
rewrite src/Part_2.py (72%)
6) branch 설정
<in>
git branch -M main
7) 올리기
<in>
git push
급하게 적고 아직 이해가 부족하여 경험을 토대로 적었다. 추후에 다시 정리하여 수정예정