형상관리/Git
Git branch 병합하기
jungmin.park
2023. 11. 2. 09:47
현재 상태
- exp 브런치는 버전 3,4를 가지고 있고
- main은 5까지 되어있다.
* commit 711f85eda1b73d691cff78ab5e810b34c5628931 (HEAD -> main)
| Author: jungmin.park <pjm9673@gmail.com>
| Date: Thu Nov 2 09:34:22 2023 +0900
|
| 5
|
| * commit 3e33a79f7229f9d1380efb12876bfa66c9258791 (exp)
| | Author: jungmin.park <pjm9673@gmail.com>
| | Date: Thu Nov 2 09:33:16 2023 +0900
| |
| | 4
| |
| * commit 54d7d726dceefd4628c9b2ac77d06eb3ffa22e8f
|/ Author: jungmin.park <pjm9673@gmail.com>
| Date: Thu Nov 2 09:31:56 2023 +0900
|
| 3
|
* commit a39a1ac6be74c39b7fbb8ffaa456eff4f1664608
| Author: jungmin.park <pjm9673@gmail.com>
| Date: Thu Nov 2 09:27:03 2023 +0900
|
| 2
|
* commit 283db00863280c03433777042b4bddeb3049703c
Author: jungmin.park <pjm9673@gmailc.om>
Date: Thu Nov 2 09:25:17 2023 +0900
1
merge [브런치이름]
exp 브런치를 main으로 병합하기
- main 브런치로 가서
- git merge exp 입력
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git checkout main
Already on 'main'
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git merge exp
Merge made by the 'ort' strategy.
f2.txt | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 f2.txt
- merge는 두개의 부모를 가진 하나의 commit 이다.
- exp에서 만들었던 f2.txt파일을 merge하면 main 브런치에서도 f2.txt가 생성되어있다.
* 92d2fb9 (HEAD -> main) Merge branch 'exp'
|\
| * 3e33a79 (exp) 4
| * 54d7d72 3
* | 711f85e 5
|/
* a39a1ac 2
* 283db00
exp도 같은 상태로 만들어주기
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git checkout exp
Switched to branch 'exp'
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git merge main
Updating 3e33a79..92d2fb9
Fast-forward
f1.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git log --branches --decorate --graph --oneline
* 92d2fb9 (HEAD -> exp, main) Merge branch 'exp'
|\
| * 3e33a79 4
| * 54d7d72 3
* | 711f85e 5
|/
* a39a1ac 2
* 283db00 1
branch '브런치이름'
- exp 브런치 삭제하기
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git checkout main
Switched to branch 'main'
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git branch -d exp
Deleted branch exp (was 92d2fb9).
(base) bagjeongmin@bagjeongmin-ui-MacBookAir gitft3 % git log --branches --decorate --graph --oneline
* 92d2fb9 (HEAD -> main) Merge branch 'exp'
|\
| * 3e33a79 4
| * 54d7d72 3
* | 711f85e 5
|/
* a39a1ac 2
* 283db00 1