[Git] ์๊ฒฉ ์ ์ฅ์ ๋ธ๋์น ๋๊ธฐํ
[ ๊นํ๋ธ ๋ธ๋์น ์์ฑ ]
GitHub: Let’s build from here
GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and fea...
github.com
[ ๋ก์ปฌ ์ ์ฅ์ ๋ธ๋์น ๋๊ธฐํ ]
- $ git branch
=> ํ์ฌ ๋ก์ปฌ ์ ์ฅ์ ๋ธ๋์น ํ์ธ
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(branch_1)
$ git branch
main
* branch_1
- $ git fetch
=> ์๊ฒฉ ์ ์ฅ์ ๋ณ๊ฒฝ ์ฌํญ ํ์ธ ๋ฐ ์ต์ ๋ธ๋์น ์ ๋ณด๋ฅผ ๋ก์ปฌ ์ ์ฅ์๋ก ๊ฐ์ ธ์ค๊ธฐ
(๊ฐ์ ธ์จ ๋ณ๊ฒฝ์ฌํญ์ ๋ก์ปฌ ๋ธ๋์น์ ์ ์ฉ๋์ง๋ ์์. ์ ์ฉ์ ์ํ ๊ฒฝ์ฐ 'git pull' ๋ช ๋ น ์ฌ์ฉ)
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(branch_1)
$ git fetch
From https://github.com/์ ์ ๋ช
/ํ๋ก์ ํธ๋ช
* [new branch] test -> origin/test
- $ git checkout -b [๋ก์ปฌ ๋ธ๋์น๋ช ] origin/[์๊ฒฉ ๋ธ๋์น๋ช ]
=> ์๋ก์ด [๋ก์ปฌ ๋ธ๋์น๋ช ] ๋ธ๋์น๋ฅผ ๋ก์ปฌ ์ ์ฅ์์ ์์ฑํจ๊ณผ ๋์์,
์๊ฒฉ ์ ์ฅ์์ origin/[์๊ฒฉ ๋ธ๋์น๋ช ]๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ด๋ฅผ ๋๊ธฐํ
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(branch_1)
$ git checkout -b test origin/test
Switched to a new branch 'test'
branch 'test' set up to track 'origin/test'.
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(test)
- $ git remote update ๋ช ๋ น์ ํตํด ๋ชจ๋ ์๊ฒฉ ์ ์ฅ์์ ์ ๋ณด๋ฅผ ์ต์ ์ํ๋ก ์ ๋ฐ์ดํธ๋ ๊ฐ๋ฅ
[ ๋ก์ปฌ ์ ์ฅ์ ๋ธ๋์น ์ด๋ ]
- $ git branch
=> ํ์ฌ ๋ก์ปฌ ์ ์ฅ์์ ๋ธ๋์น ๋ชฉ๋ก ํ์ธ
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(test)
$ git branch
main
branch_1
* test
- $ git checkout [๋ธ๋์น๋ช ]
- $ git switch [๋ธ๋์น๋ช ]
=> ๋ ๋ช ๋ น์ด ๋ค [๋ธ๋์น๋ช ]์ผ๋ก ๋ณ๊ฒฝ๋๋ ๊ฒ์ ๋์ผํ์ง๋ง, 'git checkout' ๋ช ๋ น์ ๊ฒฝ์ฐ
๋ธ๋์น ๋ณ๊ฒฝ ์ ์์ ์ค์ธ ๋ณ๊ฒฝ์ฌํญ์ ์คํ ์ด์ง ์์ญ/์์ ํด๋์ ๊ทธ๋๋ก ๋จ๊ฒจ๋๊ธฐ ๋๋ฌธ์
์ถฉ๋์ด ์๊ฒจ ์๋ฌ๊ฐ ๋ฐ์ํ ์ ์์.
git switch ๋ช ๋ น์ ๊ฒฝ์ฐ Git 2.23.0 ๋ฒ์ ์ดํ์ ๋์ ๋ ๋ช ๋ น์ด๋ก ํด๋น ๋ช ๋ น์ ํตํด
๋ธ๋์น ๋ณ๊ฒฝ ์ ์์ ์ค์ธ ๋ณ๊ฒฝ์ฌํญ์ ์๋์ผ๋ก ๋ธ๋์น์ ๋จ๊ธฐ์ง ์๊ณ ์ง์ฐ๊ณ ์ด๋ํจ.
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(test)
$ git switch branch_1
Switched to branch 'branch_1'
Your branch is up to date with 'origin/branch_1'.
[ ๋ก์ปฌ ์ ์ฅ์ ๋ธ๋์น ์ญ์ ]
- $ git branch -d [๋ธ๋์น๋ช ]
=> [๋ธ๋์น๋ช ] ๋ก์ปฌ ์ ์ฅ์ ๋ธ๋์น ์ญ์ .
์ด ๋ ์๊ฒฉ ์ ์ฅ์์๋ ์ํฅ์ ์ฃผ์ง ์์.
์ ์ ๋ช
@DESKTOP-CVATVKU MINGW64 ~/WebProjects/ํ๋ก์ ํธ๋ช
(branch_1)
$ git branch -d test
Deleted branch test (was 2754384).