ETC

TIL GIT#3

๋ฆฐ์˜ˆ์กฐ 2023. 10. 25. 19:40

์˜ค๋Š˜ ์•Œ๊ฒŒ ๋œ Git Git Git!!!

 

- dev(์‰ฝ๊ฒŒ ๋ฒ ํƒ€ ๋ธŒ๋žœ์น˜, ๋ฐฐํฌ ์ „ ํ˜‘์—… ๋ธŒ๋žœ์น˜) ์— ์žˆ๋Š” ์ฝ”๋“œ๋ฅผ pull ํ•ด์˜ฌ ๋•Œ๋Š” 

๋‚ด local ์—์„œ ๋งŒ๋“ค์–ด์ค€ dev๋กœ checkout ํ›„์— git pull origin dev 

- ๊ทธ๋ฆฌ๊ณ  ๋‚ด ์ž‘์—… ๋ธŒ๋žœ์น˜๋กœ ๊ฐ€์ ธ ์˜ค๊ณ  ์‹ถ์„ ๋• git checkout rinlogin ๋ธŒ๋žœ์น˜ ๋ณ€๊ฒฝํ•ด์„œ 

๋‹ค์‹œ git pull dev 

 

์ค‘์š”ํ•œ ๊ฒƒ! ์ฒ˜์Œ clone ํ•  ๋•Œ ๊ธฐ์กด ํ”„๋กœ์ ํŠธ ์•„๋ž˜์— ๋งŒ๋“ค๋ฉด ์•ˆ๋จ!

 

ํ„ฐ๋ฏธ๋„๋กœ ์ด๋™!

 

1. pwd - ํ˜„์žฌ ๊ฒฝ๋กœ ํ™•์ธ

2. cd - ํ•ด๋‹น ๊ฒฝ๋กœ๋กœ ์ด๋™

Ex) cd Users/joyerin/PJ 

3. ๊ทธ๋ฆฌ๊ณ  ๊ทธ ๊ฒฝ๋กœ์—์„œ git clone "repo์ฃผ์†Œ" 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํ•ด๋‹น ๊ฒฝ๋กœ์— ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ๋œ๋‹ค.

4. ์ธํ…”๋ฆฌ์ œ์ด ์‹คํ–‰์‹œ์ผœ open project ์—ด๊ณ  ์ž‘์—…ํ•˜๋ฉด ๋จ!!

 

 

GIT ERROR

๊ทธ๋ ‡๊ฒŒ branch ๋ณ€๊ฒฝํ•˜๋ฉฐ ์‹ ๋‚˜๊ฒŒ add/commit/push ํ•˜๋‹ค๊ฐ€ ๊ฐ‘์ž๊ธฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ..

default branch์ธ dev์—์„œ pull ์ด ์•ˆ๋œ๋‹ค ,,, 

 

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git branch
* dev
  main
  rinyejo
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git pull origin dev
https://github.com/wkdehf217/KioskTeamProject URL์—์„œ
 * branch            dev        -> FETCH_HEAD
ํžŒํŠธ: You have divergent branches and need to specify how to reconcile them.
ํžŒํŠธ: You can do so by running one of the following commands sometime before
ํžŒํŠธ: your next pull:
ํžŒํŠธ: 
ํžŒํŠธ:   git config pull.rebase false  # merge
ํžŒํŠธ:   git config pull.rebase true   # rebase
ํžŒํŠธ:   git config pull.ff only       # fast-forward only
ํžŒํŠธ: 
ํžŒํŠธ: You can replace "git config" with "git config --global" to set a default
ํžŒํŠธ: preference for all repositories. You can also pass --rebase, --no-rebase,
ํžŒํŠธ: or --ff-only on the command line to override the configured default per
ํžŒํŠธ: invocation.
fatal: Need to specify how to reconcile divergent branches.
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git config pull.ff only
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git pull origin dev
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 13 (delta 7), reused 13 (delta 7), pack-reused 0
์˜ค๋ธŒ์ ํŠธ ๋ฌถ์Œ ํ‘ธ๋Š” ์ค‘: 100% (13/13), 1.26 KiB | 258.00 KiB/s, ์™„๋ฃŒ.
https://github.com/wkdehf217/KioskTeamProject URL์—์„œ
 * branch            dev        -> FETCH_HEAD
   060165e..d7c17cb  dev        -> origin/dev
ํžŒํŠธ: Diverging branches can't be fast-forwarded, you need to either:
ํžŒํŠธ: 
ํžŒํŠธ:   git merge --no-ff
ํžŒํŠธ: 
ํžŒํŠธ: or:
ํžŒํŠธ: 
ํžŒํŠธ:   git rebase
ํžŒํŠธ: 
ํžŒํŠธ: Disable this message with "git config advice.diverging false"
fatal: ์ •๋ฐฉํ–ฅ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ, ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git pull --rebase
error: ๋ฆฌ๋ฒ ์ด์Šค๋กœ ํ’€ํ•˜๊ธฐ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: ์Šคํ…Œ์ด์ง•ํ•˜์ง€ ์•Š์€ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
error: ์ปค๋ฐ‹ํ•˜๊ฑฐ๋‚˜ ์Šคํƒœ์‹œ์— ๋„ฃ์œผ์‹ญ์‹œ์˜ค.
joyelin-ui-MacBookPro:KioskTeamProject joyerin$ git pull origin dev
https://github.com/wkdehf217/KioskTeamProject URL์—์„œ
 * branch            dev        -> FETCH_HEAD

์ด๋Ÿฐ ์‹์˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒ.

<์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๊ณผ์ •>

1. git config pull.rebase false .. ์•ˆ ๋จ.

2. ๊ทธ๋ž˜์„œ ๋‹ค์‹œ git fetch ํ›„์— git merge ... ์•ˆ ๋จ.

3. ๋ฌด์ž‘์ • git pull ํ•ด๋ดค์ง€๋งŒ .... ์•ˆ ๋จ.

 

๊ทธ๋ž˜์„œ

 

git log ๋ช…๋ น์–ด ์ž…๋ ฅ ํ›„์— ์–ด๋””์—์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ํ™•์ธํ–ˆ๋Š”๋ฐ 

origin/dev ๊ฐ€ ๋ฐœ๊ฒฌ๋˜์ง€ ์•Š์Œ .

์ถ”๊ฐ€๋กœ git ๋‚ด์—ญ๊นŒ์ง€ ํ™•์ธํ•ด๋ณด๋‹ˆ!

์—ฌ๊ธฐ์—์„œ ๋ฐœ๊ฒฌํ•จ! (ํŠœํ„ฐ๋‹˜์˜ ์—„์ฒญ๋‚œ ์„ค๋ช… ๋•๋ถ„ ใ…Žใ…Ž)

 

origin main์—์„œ pull ํ•œ ๋‚ด์—ญ์ด ์žˆ์–ด์•ผ ํ•˜๋Š”๋ฐ ๊ทธ๊ฒƒ์€ ์—†๊ณ 

dev์—์„œ pushํ•œ ๊ธฐ๋ก์„ ๋ฐœ๊ฒฌํ•จ.. (์ด๊ฒƒ์ด ๋ฌธ์ œ.. ๊ฐœ์ธ ์ž‘์—… ๋ธŒ๋žœ์น˜์—์„œ ํ•ด์•ผํ•จ)

์„ค๋ช…์„ ๋“ค์–ด๋ณด๋‹ˆ ๋‚ด๊ฐ€ ๋งŒ๋“  dev๋ž‘ origin dev๋ž‘ ๊ฐ™์€ ์œ„์น˜์— ์žˆ์–ด์„œ ์•ˆ๋จ. 

๊ทธ๋ž˜์„œ ๊ฒฐ๊ตญ! git branch -d(-D) dev ๋ฅผ ํ•ด์„œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œ! (๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜๋กœ ๋ณ€๊ฒฝํ›„์— ์‚ญ์ œ ๊ฐ€๋Šฅํ•จ)

main branch๋กœ checkout ํ›„์—

git branch checkout -b dev ๋‹ค์‹œ ๋งŒ๋“ค์–ด์คฌ๋‹ค!!

ํ˜„์žฌ ๋ธŒ๋žœ์น˜ ๋‹ค์‹œ ํ™•์ธํ•ด์ฃผ๊ณ ! dev์—์„œ git pull origin dev ํ•˜๋ฉด pull ์ด ์ž˜ ๋ฉ๋‹ˆ๋‹ค ใ…Žใ…Žใ…Ž

๋ช…์‹ฌ ๋ช…์‹ฌ..! ์ฝ”๋“œ ์งค ๋•Œ ๋‚ด ๊ฐœ์ธ ๋ธŒ๋žœ์น˜์—์„œ ์ž‘์—…์ค‘์ธ์ง€ ๊ผญ ํ™•์ธํ•˜๊ธฐ!! push ์ „์— ๊ฐœ์ธ๋ธŒ๋žœ์น˜์— ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ!!

 

 

 

 

์˜ค๋Š˜์€ ๋งค์šฐ ์ง€์น˜๊ณ  ํ”ผ๊ณคํ–ˆ์ง€๋งŒ ์ฆ๊ฑฐ์› ๋˜ ๋‚ ์ด๋‹ค ! ์™œ๋ƒ๋ฉด ๋“œ๋””์–ด git์— ์žฌ๋ฏธ๋ฅผ ๋ถ™์˜€๊ธฐ ๋•Œ๋ฌธ!!

์–ด์ œ ๊ฐ•์˜๋ฅผ ๊ธฐ์ ์œผ๋กœ ์˜ค๋Š˜ ํŒ€์›๋“ค์ด๋ž‘ ๊นƒ์œผ๋กœ ํ˜‘์—… ์‹œ์ž‘ํ•˜๋ฉด์„œ ๋ชจ๋ฅด๋Š” ๊ฒƒ๋“ค์„ ๋ฏธ๋ฃจ์ง€ ์•Š๊ณ  ์ ๊ทน์ ์œผ๋กœ ์ฐพ์•„๋ณด๊ณ  

ํŠœํ„ฐ๋‹˜๊ป˜ ๋งŽ์€ ์งˆ๋ฌธ์„ ํ–ˆ๋”๋‹ˆ..! ์–ด๋ ต์ง€๋งŒ ์ƒ๊ฐ๋ณด๋‹ค ๊ฐ„๋‹จํ•œ ๊ฒƒ๋“ค์ด ๋งŽ์•˜๊ณ  ์™œ๋“ค ๊ทธ๋ ‡๊ฒŒ  git git ํ•˜๋Š”์ง€ ์•Œ๊ฒŒ ๋๋‹ฌ๊นŒ?!

git์€ ๋Š˜ ์• ์ฆ์˜ ์กด์žฌ์˜€๋Š”๋ฐ ...  git์— ๊ด€ํ•œ ๊ฐˆ์ฆ์ด ๋งŽ์ด ํ•ด๊ฒฐ๋˜์—ˆ๋‹ค!!

 

์œผํ•˜ํ•˜ ์ด๋ ‡๊ฒŒ ๊ท€์—ฌ์šด ์ƒ์–ด๋„ ์ƒ๊ฒผ๋‹ค !! 

'ETC' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

์—๋Ÿฌ ํ•ด๊ฒฐ  (0) 2023.12.17
TIL GIT #2  (0) 2023.10.24
TIL GIT #1  (0) 2023.10.23
SpringToolSuite4 ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์—†์Œ.  (0) 2022.11.03