1. branch 만들기
두 사람이 각 branch에서 작업한다고 가정
➜ git_test_develop2 git:(main) git branch develop1
➜ git_test_develop2 git:(main) git branch develop2
2. git clone 두번 하기
➜ git_test git clone https://github.com/JellytoDev/git_test.git
Cloning into 'git_test'...
remote: Enumerating objects: 44, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 44 (delta 17), reused 39 (delta 12), pack-reused 0
Receiving objects: 100% (44/44), 6.40 MiB | 7.84 MiB/s, done.
Resolving deltas: 100% (17/17), done.
➜ git_test
➜ git_test mv git_test git_test_develop1
➜ git_test git clone https://github.com/JellytoDev/git_test.git
Cloning into 'git_test'...
remote: Enumerating objects: 44, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 44 (delta 17), reused 39 (delta 12), pack-reused 0
Receiving objects: 100% (44/44), 6.40 MiB | 9.07 MiB/s, done.
Resolving deltas: 100% (17/17), done.
➜ git_test mv git_test git_test_develop2
3. develop1 코드 만들기
➜ git_test_develop2 git:(main) git checkout develop1
Switched to branch 'develop1'
➜ git_test_develop2 git:(develop1) nano develop1_code.py
GNU nano 6.2 develop1_code.py
print("develop1 code! hello!!!!")
➜ git_test_develop2 git:(develop1) ✗ ls
chromedriver.exe develop1_code.py main.py screenshot.png wiz_test.py
4. develop1 commit / push
➜ git_test_develop1 git:(develop1) git add .
➜ git_test_develop1 git:(develop1) git commit -m "develop1 commit"
On branch develop1
nothing to commit, working tree clean
➜ git_test_develop1 git:(develop1) git push origin develop1
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'develop1' on GitHub by visiting:
remote: https://github.com/JellytoDev/git_test/pull/new/develop1
remote:
To https://github.com/JellytoDev/git_test.git
* [new branch] develop1 -> develop1
5.develop2 코드 만들기
➜ git_test_develop2 git:(develop1) ✗ git checkout develop2
Switched to branch 'develop2'
➜ git_test_develop2 git:(develop2) ✗ nano develop2_code.py
print("develop2 code! hello2!!!")
➜ git_test_develop2 git:(develop2) ✗ ls
chromedriver.exe develop2_code.py main.py screenshot.png wiz_test.py
5. 1과 같은 방법으로 commit/push
6. merge branch 만들기
원격 환경에서 작업 및 병합을 위해 merge beranch 생성
➜ git_test git clone https://github.com/JellytoDev/git_test.git
Cloning into 'git_test'...
remote: Enumerating objects: 39, done.
remote: Counting objects: 100% (39/39), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 39 (delta 14), reused 35 (delta 10), pack-reused 0
Receiving objects: 100% (39/39), 6.40 MiB | 7.79 MiB/s, done.
Resolving deltas: 100% (14/14), done.
➜ git_test ls
git_test git_test_develop1 git_test_develop2
➜ git_test mv git_test git_test_merge
➜ git_test ls
git_test_develop1 git_test_develop2 git_test_merge
➜ git_test cd git_test_merge
➜ git_test_merge git:(main) git branch dev
➜ git_test_merge git:(main) git chekout dev
git: 'chekout' is not a git command. See 'git --help'.
The most similar command is
checkout
➜ git_test_merge git:(main) git checkout dev
Switched to branch 'dev'
➜ git_test_merge git:(dev)
7. remote update
원격에서 push한 기록들을 update로 가져와 log를 추적
git_test_merge git:(dev) git remote update
Fetching origin
8. merge
merge branch인 dev에서 develop1, develop2 merge
➜ git_test_develop1 git:(develop1) git merge origin/develop1
➜ git_test_develop1 git:(develop1) git merge origin/develop2
9. develop1,develop2 에서 git pull 하기
업데이트된 dev branch 코드 pull 하기
➜ git_test_develop1 git:(develop1) git pull origin dev
➜ git_test_develop2 git:(develop2) git pull origin dev