본문 바로가기
Programing/Git

[GIT] Git 활용 예제

by 꾸압 2022. 5. 30.

 

<git 영역 정리>

 

1) Working Directory (Local)

  => 개인 코드 작성 

 

2)  Staging 영역

  => git add 를 통해 수정된 코드를 올리는 영역

 

3) Repository

  => git commit을 통해 최종 수정본 제출

 


 

<git 저장소에 commit 방법>

 

gitbash 를 엶 or VScode 의 터미널 open

 

$ git config --local user,name "사용자 이름"

=> 사용자 이름 등록

 

$ git config --local user.email "사용자 이메일"

=> 사용자 이메일 등록

 

$ git config --list

=> 사용자가 설정한 모든 것을 보여줌. 설정 확인하자

 

$ git init

=> repository 에 가장 먼저 해야할 초기화

 

$git add .

=> 현재 directory의 모든 변경 내용을 staging 영역으로 넘김

 

$ git commit -m "first commit"

=> commit 분기 생성 

 

$ git remote add origin "저장할 Repository 의 URL"

=> 저장할 Repository로 사용자의 Source Code 를 전송

=> origin은 remote repository의 이름으로, 다른 이름으로 바꿔도 됨

 

$ git remote -v

=> remote 저장소와의 연결 확인

 

$ git branch "생성할 이름"

=> branch 형성. 

=> default name 은 "main" (default name이 "master"인건 과거 버전)

 

$ git branch

=> 존재하는 branch 확인

 

$ git checkout "변경할 branch 이름"

=> branch 변경

 

$ git push origin [branch 이름]

=> 전송

=> git push [origin라는 저장소][master 라는 branch]

=> $ git push origin +master (강제 push)

 

$ git log

=> commit 이력 확인

 

$ git pull

=> 타인의 Remote Repository에 update한 파일이 있을 때, Remote 저장소와 내 local 저장소를 동일하게 만드는 기능

 


 

<작성 글에 포함된 내용은 없으나 참고하면 유용한 사이트>

https://coding-groot.tistory.com/97

 

<참조>

https://git-scm.com/book/ko/v2/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-Git-%EC%B5%9C%EC%B4%88-%EC%84%A4%EC%A0%95

https://wordbe.tistory.com/entry/Git-%EC%82%AC%EC%9A%A9-%EB%B0%A9%EB%B2%95-%EC%A0%95%EB%A6%ACcommit-push-pull-request-merge-%EB%93%B1

 

'Programing > Git' 카테고리의 다른 글

[Git] non-fast-forward 에러  (0) 2022.06.18
[Git] 특정 File 업로드 방법  (0) 2022.06.13
[GIT] GitHub 프로젝트 보안  (0) 2022.05.16
[GIT] Git 활용 예제  (0) 2022.05.15

댓글