-
Git WorkflowGit 2021. 10. 18. 11:37
Git을 활용한 Workflow 정리
< Git Intro >
1. Git : 소스 코드 기록을 관리하고 추적할 수 있는 버전 관리 시스템
2. GitHub : Git Repository를 관리할 수 있는 클라우드 기반 서비스
< Git Workflow > - 이미 존재하는 Project(Repository)
1. 다른 Remote Repository를 내 Remote Repository로 가져오기
: GitHub접속 후 가져올 Remote Repository 접속 -> 우측 상단의 Fork 클릭
2. 내 Remote Repository에 있는 코드를 Local Repository(내 컴퓨터)로 가져오기
git clone <레파지토리 주소> # example git clone https://github.com/tkdgns25300/Explore-The-World
3. Local Repository에서 파일 수정
git status, git add, git diff, 및 git commit 등 여러 명령어 이용
< Git의 세가지 상태 >
- nomodified : 기존에 Commit했던 파일을 수정하지 않은 상태.
- Modified : 기존에 Commit했던 파일을 수정한 상태.
- Staged : commit이 가능한 상태. 수정한 파일을 commit하기 위해서는 staged area에 add 하는 작업이 필요.
4. Local Repository에서 변경(commit)된 파일들을 Remote Repository에 업로드
git push <user> <branch> # example git push origin master
- 리모트에 있는 origin의 master브랜치에 Local Repository의 변경사항 업로드
6. Pull Request를 이용해 Remote Repository에 Push 해 놓은 변경사항을 작업하는 사람들에게 알리기
자신의 Remote Repository에 push 후 GitHub상의 해당 Repository 접속 -> Pull Request 클릭
< Git Workflow > - 새로 시작하는 Project(Repository)
1. Git을 이용해 프로젝트 시작
: git init - 현재 디렉토리를 Git Local Repository 로 변경
git init
2. Local Repository를 Remote Repository와 연결
: Github에 Repository를 하나 만든 후, 아래 명령어 입력
git remote add <username> <repository 주소>
- username이라는 이름으로 Remote repository 등록
3. 페어의 Remote Repository와 내 Local Repository 연결
git remote add <pairname> <Repository 주소>
- pairname이라는 이름으로 Remote repository 등록
+. 아래 명령어를 통해 , 현재의 Local Repository와 연결된 모든 Remote Repository 확인.
git remote -v
4. Remote Repository의 작업 내용을 Local Repository로 가져오기
: 받아오는 내용은 자동으로 병합됩니다.
git pull <name> <branch>
+. 내용을 받아왔는데, 수정내용이 자동병합되지 않고 충돌할 때 (Merge Conflict 발생)
-> git status 명령 이용해 어떤 파일이 충돌하고 있는지 확인-> 파일 수정 후 git add - git commig - git push
5. Local Repository의 수정 내용을 Remote Repository에 업로드
git push <user> <branch> # example git push origin master
- 리모트에 있는 origin의 master브랜치에 Local Repository의 변경사항 업로드
Reference : https://guides.github.com/introduction/flow/
Understanding the GitHub flow · GitHub Guides
Create a branch When you're working on a project, you're going to have a bunch of different features or ideas in progress at any given time – some of which are ready to go, and others which are not. Branching exists to help you manage this workflow. When
guides.github.com
'Git' 카테고리의 다른 글
How to backtrack in Git (0) 2021.10.18 Introduction to Git (0) 2021.10.18