pull request
- Fork
- clone, remote설정
- branch 생성
- 수정 작업 후 add, commit, push
- Pull Request 생성
- 코드리뷰, Merge Pull Reqest
- Merge 이후 branch 삭제 및 동기화
1. 프로젝트를 포크함
자신의 workspace에 open gitbash
2.git clone (로컬에 포크된 대상주소URL)
3.-- git remote add (별칭) 원본 레포지터리(포크한 레포지터리 대상)
$ git remote add real-cbos https://github.com/astbyte/cbos.git
4. 원격 저장소 설정 현황 확인방법 $ git remote -v
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git remote -v
origin https://github.com/tmxhsk99/cbos.git (fetch)
origin https://github.com/tmxhsk99/cbos.git (push)
real-cbos https://github.com/astbyte/cbos.git (fetch)
real-cbos https://github.com/astbyte/cbos.git (push)
6. 새로운 브랜치를 만듬
- 자신의 로컬 컴퓨터에서 코드를 추가하는 작업은 branch를 만들어서 진행한다.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git checkout -b develop
Switched to a new branch 'develop'
7. git add , commit, push
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git add -A
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit -m "full request test"
[develop 0ed7c1e] full request test
2 files changed, 4 insertions(+), 3 deletions(-)
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git push origin develop
Counting objects: 16, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (16/16), 1.13 KiB | 230.00 KiB/s, done.
Total 16 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
remote:
remote: Create a pull request for 'develop' on GitHub by visiting:
remote: https://github.com/tmxhsk99/cbos/pull/new/develop
remote:
To https://github.com/tmxhsk99/cbos.git
* [new branch] develop -> develop
처음 pullrequest할땐 코드에 알람으로 뜨지만 여러번 커밋하면 밑에 그림처럼 들어가야 됨
commiter 의 pull request ↑
관리자는 코드 확인후 merge를 실행함
7. Merge 이후 동기화 및 branch 삭제
- 원본 저장소에 Merge가 완료되면 로컬 코드와 원본 저장소의 코드를 동기화 한다.
git pull real-cbos
- 작업하던 로컬의 branch를 삭제한다.
master 로 체크아웃 후에 삭제한다.
git branch -D develop
# 코드 동기화 $ git pull real-cbos(remote 별명) # 브랜치 삭제 $ git branch -d develop(브랜치 별명)
- 나중에 추가로 작업할 일이 있으면 git pull real-cbos(remote 별명) 명령을 통해 원본 저장소와 동기화를 진행하고 3~7을 반복한다.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git remote add real-cbos https://github.com/astbyte/cbos.git
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git remote -v
origin https://github.com/tmxhsk99/cbos.git (fetch)
origin https://github.com/tmxhsk99/cbos.git (push)
real-cbos https://github.com/astbyte/cbos.git (fetch)
real-cbos https://github.com/astbyte/cbos.git (push)
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git checkout -b develop
Switched to a new branch 'develop'
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git branch
* develop
master
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git add -A
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit -m "full request test"
[develop 0ed7c1e] full request test
2 files changed, 4 insertions(+), 3 deletions(-)
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git push origin develop
Counting objects: 16, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (16/16), 1.13 KiB | 230.00 KiB/s, done.
Total 16 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
remote:
remote: Create a pull request for 'develop' on GitHub by visiting:
remote: https://github.com/tmxhsk99/cbos/pull/new/develop
remote:
To https://github.com/tmxhsk99/cbos.git
* [new branch] develop -> develop
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit -m "second commit"
On branch develop
Changes not staged for commit:
modified: src/main/webapp/WEB-INF/view/hello.jsp
no changes added to commit
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git add -A
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit -m "second commit"
[develop 4af631e] second commit
1 file changed, 1 insertion(+), 1 deletion(-)
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git push origin develop
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 556 bytes | 278.00 KiB/s, done.
Total 8 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/tmxhsk99/cbos.git
0ed7c1e..4af631e develop -> develop
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git branch
* develop
master
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git push origin develop
Everything up-to-date
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git add -A
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit "second2"
error: pathspec 'second2' did not match any file(s) known to git.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git commit -m "second 2"
[develop 54ab4b6] second 2
1 file changed, 1 insertion(+), 1 deletion(-)
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git push origin develop
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 555 bytes | 277.00 KiB/s, done.
Total 8 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/tmxhsk99/cbos.git
4af631e..54ab4b6 develop -> develop
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git pull real-cbos
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/astbyte/cbos
* [new branch] master -> real-cbos/master
You asked to pull from the remote 'real-cbos', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git branch -d develop
error: Cannot delete branch 'develop' checked out at 'C:/Spring/workspace3/cbos'
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (develop)
$ git checkout origin
Note: checking out 'origin'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 1855e02 first commit
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos ((1855e02...))
$ git branch
* (HEAD detached at origin/master)
develop
master
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos ((1855e02...))
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git branch -d develop
error: The branch 'develop' is not fully merged.
If you are sure you want to delete it, run 'git branch -D develop'.
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git branch -D develop
Deleted branch develop (was 54ab4b6).
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$ git branch
* master
MSI@DESKTOP-R7UTO2C MINGW64 /c/Spring/workspace3/cbos (master)
$