/
20240809 Git ๊ธฐ์ดˆ ๋ฐ ํ™œ์šฉ ๊ฐ€์ด๋“œ

20240809 Git ๊ธฐ์ดˆ ๋ฐ ํ™œ์šฉ ๊ฐ€์ด๋“œ

ย 

ย 

ย 

ย 

ย 

1. Git ํ”„๋กœ์„ธ์Šค ๊ฐœ์š”

ย 

2. Git ์•„ํ‚คํ…์ฒ˜ ๊ฐœ์š”

ย 

3. ์†Œ์Šค ๊ฐ€์ ธ์˜ค๊ธฐ : git clone

ย 

image-20240808-012930.png

ย 

image-20240808-013010.png

ย 

์†Œ์Šค๋ฅผ cloneํ•˜๊ณ  ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•œ๋‹ค.

git clone <์†Œ์Šค URL> <๋””๋ ‰ํ† ๋ฆฌ๋ช…> cd <๋””๋ ‰ํ† ๋ฆฌ๋ช…>

ย 

ADO-git-handson# git clone https://zerobig-devops4demo@dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo 20240808_git_handson Cloning into '20240808_git_handson'... Password for 'https://zerobig-devops4demo@dev.azure.com': warning: You appear to have cloned an empty repository. ADO-git-handson# cd 20240808_git_handson/ ADO-git-handson# ls -rlht total 0 ADO-git-handson#

ย 

ย 

4. git ๋ช…๋ น ๋ง›๋ณด๊ธฐ : add/commit/push ์‹คํ–‰ํ•˜๊ธฐ

ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ์ปค๋ฐ‹ ํ›„ ๋ฆฌ๋ชจํŠธ๋กœ ํ‘ธ์‹œํ•œ๋‹ค.

vi README.md git status git add . git commit -m "First Commit" git status git push

ย 

ADO-git-handson# vi README.md ADO-git-handson# git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) README.md nothing added to commit but untracked files present (use "git add" to track) ADO-git-handson# git add . ADO-git-handson# git commit -m "First Commit" [master (root-commit) 18c1fe6] First Commit 1 file changed, 1 insertion(+) create mode 100644 README.md ADO-git-handson# git status On branch master Your branch is based on 'origin/master', but the upstream is gone. (use "git branch --unset-upstream" to fixup) nothing to commit, working tree clean ADO-git-handson# git push Password for 'https://zerobig-devops4demo@dev.azure.com': Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 235 bytes | 13.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Analyzing objects... (3/3) (9 ms) remote: Validating commits... (1/1) done (0 ms) remote: Storing packfile... done (68 ms) remote: Storing index... done (44 ms) To https://dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo * [new branch] master -> master ADO-git-handson#

ย 

๋ฆฌ๋ชจํŠธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ƒˆ๋กœ๊ณ ์นจํ•˜์—ฌ ํ‘ธ์‹œ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•œ๋‹ค.

image-20240808-013705.png

Repos > Commits๋ฅผ ์„ ํƒํ•˜์—ฌ ๋‚ด์šฉ์„ ์‚ดํŽด๋ณธ๋‹ค.

image-20240808-015850.png

๋กœ์ปฌ์—์„œ git log ๋ช…๋ น์„ ํ†ตํ•ด commit์— ๋Œ€ํ•œ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•ด๋ณธ๋‹ค.

git log git log --oneline

ย 

ADO-git-handson# git log commit 18c1fe6382799469b6e433d6269021dddd77a760 (HEAD -> master, origin/master) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 10:35:48 2024 +0900 First Commit ADO-git-handson# ADO-git-handson# ADO-git-handson# git log --oneline 18c1fe6 (HEAD -> master, origin/master) First Commit ADO-git-handson#

ย 

ย 

5. ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…ํ•˜๊ธฐ

ํ˜„์žฌ ๋ธŒ๋žœ์น˜๋ฅผ ํ™•์ธํ•˜๊ณ  ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…์„ ์ค€๋น„ํ•œ๋‹ค.

git branch git checkout -b feat-1-colors

ย 

ADO-git-handson# git branch * master ADO-git-handson# git checkout -b feat-1-colors Switched to a new branch 'feat-1-colors' ADO-git-handson# git branch * feat-1-colors master ADO-git-handson# ls -rlht total 0 -rwxrwxrwx 1 zerobig zerobig 21 Aug 8 10:35 README.md ADO-git-handson# cat README.md 20240808_git_handson ADO-git-handson#

ย 

VS Code๋ฅผ ๋„์›Œ์„œ colors.txt ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ๋‚ด์šฉ์„ ์ž…๋ ฅ ํ›„ ์ €์žฅํ•œ๋‹ค.

code .

ย 

ADO-git-handson# git branch * master
image-20240808-020815.png

ํ„ฐ๋ฏธ๋„๋กœ ๋Œ์•„์™€ git status ๋ช…๋ น์„ ์ˆ˜ํ–‰ํ•˜์—ฌ ์ƒํƒœ๋ฅผ ํ™•์ธํ•œ๋‹ค.

git status

ย 

ADO-git-handson# git status On branch feat-1-colors Untracked files: (use "git add <file>..." to include in what will be committed) colors.txt nothing added to commit but untracked files present (use "git add" to track) ADO-git-handson#

ย 

๋‹ค์‹œ ์ปค๋ฐ‹ ํ›„ ๋ฆฌ๋ชจํŠธ๋กœ ํ‘ธ์‹œํ•œ๋‹ค.

ADO-git-handson# git add . ADO-git-handson# git staus git: 'staus' is not a git command. See 'git --help'. The most similar command is status ADO-git-handson# git status On branch feat-1-colors Changes to be committed: (use "git restore --staged <file>..." to unstage) new file: colors.txt ADO-git-handson# git commit -m "Add colors.txt" [feat-1-colors b5ecbfd] Add colors.txt 1 file changed, 3 insertions(+) create mode 100644 colors.txt ADO-git-handson# git status On branch feat-1-colors nothing to commit, working tree clean ADO-git-handson# git push fatal: The current branch feat-1-colors has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin feat-1-colors ADO-git-handson# git push --set-upstream origin feat-1-colors Password for 'https://zerobig-devops4demo@dev.azure.com': Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 8 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 294 bytes | 24.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Analyzing objects... (3/3) (6 ms) remote: Validating commits... (1/1) done (0 ms) remote: Storing packfile... done (36 ms) remote: Storing index... done (45 ms) To https://dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo * [new branch] feat-1-colors -> feat-1-colors Branch 'feat-1-colors' set up to track remote branch 'feat-1-colors' from 'origin'. ADO-git-handson#

ย 

๋ฆฌ๋ชจํŠธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ƒˆ๋กœ๊ณ ์นจํ•˜์—ฌ ํ‘ธ์‹œ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•œ๋‹ค.

image-20240808-021844.png

์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜ feat-1-colors๋ฅผ ์„ ํƒํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•œ๋‹ค.

master ๋ธŒ๋žœ์น˜์—๋Š” ์กด์žฌํ•˜์ง€ ์•Š๋Š” colors.txt ํŒŒ์ผ์ด ์กด์žฌํ•จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image-20240808-040814.png

Repos > Commits๋ฅผ ์„ ํƒํ•˜์—ฌ ๋‘ ๋ธŒ๋žœ์น˜์˜ ๋‚ด์šฉ์„ ๋น„๊ตํ•˜์—ฌ์—ฌ ์‚ดํŽด๋ณธ๋‹ค.

# master

image-20240808-050757.png

# feat-1-colors

image-20240808-050723.png

feat-1-colors ๋ธŒ๋žœ์น˜์—๋Š” colors.txt๊ฐ€ ์ถ”๊ฐ€๋˜์–ด ์žˆ์œผ๋ฉฐ ํ•˜๋‚˜์˜ ์ปค๋ฐ‹์ด ๋” ์ƒ๊ฒจ ์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋Š” ๋กœ์ปฌ์˜ ํ„ฐ๋ฏธ๋„์—์„œ๋„ git log ๋ช…๋ น์„ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

git log git checkout master git log

ย 

ADO-git-handson# git log commit b5ecbfdf8b941800654effe47efdb441bb54862e (HEAD -> feat-1-colors, origin/feat-1-colors) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 11:12:21 2024 +0900 Add colors.txt commit 18c1fe6382799469b6e433d6269021dddd77a760 (origin/master, master) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 10:35:48 2024 +0900 First Commit ADO-git-handson# ADO-git-handson# git checkout master Switched to branch 'master' Your branch is up to date with 'origin/master'. ADO-git-handson# git log commit 18c1fe6382799469b6e433d6269021dddd77a760 (HEAD -> master, origin/master) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 10:35:48 2024 +0900 First Commit ADO-git-handson#

ย 

HEAD ํฌ์ธํ„ฐ

HEAD๋Š” ํ˜„์žฌ ๋ธŒ๋žœ์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ์ด๋ฉฐ, ๋ธŒ๋žœ์น˜๋Š” ๋ธŒ๋žœ์น˜์— ๋‹ด๊ธด ์ปค๋ฐ‹ ์ค‘ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ์ปค๋ฐ‹์„ ๊ฐ€๋ฆฌํ‚จ๋‹ค. ์ง€๊ธˆ์˜ HEAD๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๋Š” ์ปค๋ฐ‹์€ ๋ฐ”๋กœ ๋‹ค์Œ ์ปค๋ฐ‹์˜ ๋ถ€๋ชจ๊ฐ€ ๋œ๋‹ค. ๋‹จ์ˆœํ•˜๊ฒŒ ์ƒ๊ฐํ•˜๋ฉด HEAD๋Š” *ํ˜„์žฌ ๋ธŒ๋žœ์น˜ ๋งˆ์ง€๋ง‰ ์ปค๋ฐ‹์˜ ์Šค๋ƒ…์ƒท*์ด๋‹ค.

image-20240808-051227.png

ย 

ย 

6. Pull Request ์ˆ˜ํ–‰ํ•˜๊ธฐ

ย 

Azure Repo > Branches๋กœ ์ด๋™ํ•˜์—ฌ Create a pull request๋ฅผ ์„ ํƒํ•œ๋‹ค.

image-20240808-051917.png

ย 

์ƒ์„ธํ•œ ์š”์ฒญ ๋‚ด์—ญ ์ž‘์„ฑ, Reviewer ์ถ”๊ฐ€ ํ›„ Create๋ฅผ ํด๋ฆญํ•œ๋‹ค.

image-20240808-052445.png

Complete๋ฅผ ํด๋ฆญํ•˜์—ฌ master ๋ธŒ๋žœ์น˜์— ๋ณ‘ํ•ฉ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค.

image-20240808-052657.png

Complete merge๋ฅผ ์„ ํƒํ•œ๋‹ค.

image-20240808-053154.png

์ •์ƒ์ ์œผ๋กœ ๋ณ‘ํ•ฉ์ด ์ด๋ฃจ์–ด์กŒ์Œ์„ ํ™•์ธํ•œ๋‹ค.

image-20240808-054126.png

Repos > Commits๋ฅผ ์„ ํƒํ•˜์—ฌ ๋‘ ๋ธŒ๋žœ์น˜์˜ ๋‚ด์šฉ์„ ๋น„๊ตํ•˜์—ฌ ์‚ดํŽด๋ณธ๋‹ค.

master ๋ธŒ๋žœ์น˜์— Merged ์ปค๋ฐ‹์ด ์ถ”๊ฐ€๋˜์–ด ์žˆ์œผ๋ฉฐ ์ปค๋ฐ‹ ์ด๋ ฅ์ด ์ผ์น˜ํ•˜๊ณ  ์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

# master

image-20240808-060048.png

# feat-1-colors

image-20240808-060112.png

์ด๋Š” ๋กœ์ปฌ์˜ ํ„ฐ๋ฏธ๋„์—์„œ๋„ git log ๋ช…๋ น์„ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

git log git log --oneline --graph git checkout master git log git log --oneline --graph

ย 

ADO-git-handson# git log commit b5ecbfdf8b941800654effe47efdb441bb54862e (HEAD -> feat-1-colors, origin/feat-1-colors) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 11:12:21 2024 +0900 Add colors.txt commit 18c1fe6382799469b6e433d6269021dddd77a760 Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 10:35:48 2024 +0900 First Commit ADO-git-handson# git log --oneline --graph * b5ecbfd (HEAD -> feat-1-colors, origin/feat-1-colors) Add colors.txt * 18c1fe6 First Commit ADO-git-handson# ADO-git-handson# git checkout master Switched to branch 'master' Your branch is up to date with 'origin/master'. ADO-git-handson# git log commit 3e5344588a59bec19069ded7c22707e7fdb47bf3 (HEAD -> master, origin/master) Merge: 18c1fe6 b5ecbfd Author: ์˜๋Œ€ ๊น€ <zerobig.kim@gmail.com> Date: Thu Aug 8 05:32:32 2024 +0000 Merged PR 57: Add colors.txt Add colors.txt contains the lists of our colors we can provide commit b5ecbfdf8b941800654effe47efdb441bb54862e (origin/feat-1-colors, feat-1-colors) Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 11:12:21 2024 +0900 Add colors.txt commit 18c1fe6382799469b6e433d6269021dddd77a760 Author: Zerobig <zerobig.kim@gmail.com> Date: Thu Aug 8 10:35:48 2024 +0900 First Commit ADO-git-handson# git log --oneline --graph * 3e53445 (HEAD -> master, origin/master) Merged PR 57: Add colors.txt |\ | * b5ecbfd (origin/feat-1-colors, feat-1-colors) Add colors.txt |/ * 18c1fe6 First Commit ADO-git-handson# ls -rlht total 0 -rwxrwxrwx 1 zerobig zerobig 21 Aug 8 10:35 README.md -rwxrwxrwx 1 zerobig zerobig 14 Aug 8 14:55 colors.txt ADO-git-handson# cat colors.txt Red Green BlueADO-git-handson#

ย 

# master

image-20240808-060646.png

# feat-1-colors

image-20240808-060616.png

ย 

์ฐธ๊ณ 

ํ˜„์žฌ ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ๋Š” ๊ฐ„๋‹จํžˆ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ณธ์ธ์ด ์ง์ ‘ Pull Request๋ฅผ ์š”์ฒญํ•˜๊ณ  ์ฒ˜๋ฆฌํ•˜์ง€๋งŒ ์‹ค์ œ๋กœ๋Š” ๊ถŒํ•œ ์žˆ๋Š” ๊ฒ€ํ† ์ž๋ฅผ ์ง€์ •ํ•˜๊ณ  ํ•ด๋‹น ๊ฒ€ํ† ์ž๋ฅผ ํ†ตํ•ด ์ฝ”๋“œ ๊ฒ€ํ†  ๋ฐ ํ™•์ธ์„ ๋ฐ›์•„์•ผ ํ•œ๋‹ค.

Pull Request๋ฅผ ์š”์ฒญํ•˜๊ฒŒ ๋˜๋ฉด Reviewer์—๊ฒŒ ์š”์ฒญ์ด ์ „๋‹ฌ๋˜๋ฉฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด Files ํƒญ์—์„œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ํ™•์ธํ•˜๊ณ  ๊ด€๋ จ Comment๋ฅผ ๋‚จ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

ย 

ย 

7. Brach ์ „๋žต ์ˆ˜๋ฆฝํ•˜๊ธฐ

ย 

Git ๋ธŒ๋žœ์น˜ ์ „๋žต ์ฑ„ํƒ

ํ˜„์žฌ master ๋ธŒ๋žœ์น˜ ๋‚ด์˜ ์ฝ”๋“œ๋Š” ์‰ฝ๊ฒŒ ์ ‘๊ทผํ•˜์—ฌ ์ฝ”๋“œ ๋ณ€๊ฒฝ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ์ƒํƒœ์ด๋ฏ€๋กœ ์ด์— ๋Œ€ํ•œ ๋ณด์™„์ด ํ•„์š”ํ•˜๋‹ค. ์†Œ์œ„ โ€œGit ๋ธŒ๋žœ์น˜ ์ „๋žตโ€์—…๋ฐ์ดํŠธ ํ•  ์ˆ˜ ์žˆ๋Š” ๋ณด์•ˆ์ ์œผ๋กœ ์ทจ์•ฝํ•œ ์ƒํƒœ์ด๋‹ค.

Git์€ ๋ฒ„์ „ ์ œ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๊ณต์œ ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์œ ์—ฐํ•˜๊ฒŒ ์ œ๊ณตํ•˜๋ฉฐ ํŒ€์€ ์ด๋Ÿฌํ•œ ์œ ์—ฐ์„ฑ๊ณผ ์ผ๊ด€๋œ ๋ฐฉ์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ๊ณต๋™ ์ž‘์—…ํ•˜๊ณ  ๊ณต์œ ํ•ด์•ผ ํ•˜๋Š” ํ•„์š”์„ฑ ์‚ฌ์ด์˜ ๊ท ํ˜•์„ ์ฐพ์•„์•ผ ํ•œ๋‹ค.

ํŒ€ ๊ตฌ์„ฑ์›์€ ๋‹ค๋ฅธ ํŒ€์›๊ณผ ๊ณต์œ ๋˜๋Š” Git ๋ธŒ๋žœ์น˜๋ฅผ ํ†ตํ•ด ์ฝ”๋“œ ๋ณ€๊ฒฝ ์‚ฌํ•ญํ•ญ์„ ๊ฒŒ์‹œ, ๊ณต์œ , ๊ฒ€ํ†  ๋ฐ ๋ฐ˜๋ณตํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. ์ด๋Ÿฌํ•œ ํŒ€์„ ์œ„ํ•œ ๋ธŒ๋žœ์น˜ ์ „๋žต์„ ์ฑ„ํƒํ•œ๋‹ค. ๋” ํšจ์œจ์ ์œผ๋กœ ํ˜‘์—…ํ•˜๊ณ  ๋ฒ„์ „ ์ œ์–ด์— ๋Œ€ํ•œ ๊ด€๋ฆฌ ์‹œ๊ฐ„์„ ์ค„์ด๊ณ  ์ฝ”๋“œ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๋ฐ ๋” ๋งŽ์€ ์‹œ๊ฐ„์„ ํ• ์• ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

๋‹ค์Œ ๋ธŒ๋žœ์น˜ ์ „๋žต์€ Microsoft์—์„œ Git์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋ฉฐ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Microsoft์—์„œ Git์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ฐธ์กฐํ•œ๋‹ค.

image-20240809-000642.png

๋ธŒ๋žœ์น˜ ์ „๋žต์„ ๋‹จ์ˆœํ•˜๊ฒŒ ์œ ์ง€ํ•œ๋‹ค. ๋‹ค์Œ ์„ธ ๊ฐ€์ง€ ๊ฐœ๋…์œผ๋กœ ์ „๋žต์„ ๋นŒ๋“œํ•œ๋‹ค.

  • ์ƒˆ๋กœ์šด ๋ชจ๋“  ๊ธฐ๋Šฅ๊ณผ ๋ฒ„๊ทธ ์ˆ˜์ •์— feature ๋ธŒ๋žœ์น˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

  • Pull Request๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ feature ๋ธŒ๋žœ์น˜๋ฅผ master ๋ธŒ๋žœ์น˜์— ๋ณ‘ํ•ฉํ•œ๋‹ค.

  • ๊ณ ํ’ˆ์งˆ์˜ ์ตœ์‹  master ๋ธŒ๋žœ์น˜๋ฅผ ์œ ์ง€ํ•œ๋‹ค..

์ด๋Ÿฌํ•œ ๊ฐœ๋…์„ ํ™•์žฅํ•˜๊ณ  ๋ชจ์ˆœ์„ ํ”ผํ•˜๋Š” ์ „๋žต์„ ํ†ตํ•ด ํŒ€์€ ์ผ๊ด€๋˜๊ณ  ๋”ฐ๋ฅด๊ธฐ ์‰ฌ์šด ๋ฒ„์ „ ์ œ์–ด ์›Œํฌํ”Œ๋กœ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

ย 

ย 

Git ๋ธŒ๋žœ์น˜ ์ „๋žต ๊ตฌ์„ฑ

ย 

Azure Repo > files๋กœ ์ด๋™ํ•˜์—ฌ master ๋ธŒ๋žœ์น˜์—์„œ colors.txt๋ฅผ ์„ ํƒํ•˜๊ณ  Edit์„ ์„ ํƒํ•œ๋‹ค.

image-20240809-001052.png

Pink๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  Commit์„ ์„ ํƒํ•œ๋‹ค.

image-20240809-001433.png

๋‹ค์‹œ Commit์„ ์„ ํƒํ•œ๋‹ค.

image-20240809-001615.png

ํŒŒ์ผ์ด ์ˆ˜์ •๋˜๊ณ  ํ•˜๋‚˜์˜ Commit์ด ์ƒ์„ฑ๋˜์—ˆ๋‹ค.

์ด์ œ master ๋ธŒ๋žœ์น˜๋ฅผ ๋ณดํ˜ธํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์„ฑ์„ ํ•ด๋ณด๊ฒ ๋‹ค.

Azure Repo > Branches๋กœ ์ด๋™ํ•˜์—ฌ master ๋ธŒ๋žœ์น˜๋ฅผ ์„ ํƒํ•˜๊ณ  ์ถ”๊ฐ€ ์˜ต์—์„œ branch policies๋ฅผ ์„ ํƒํ•˜๊ณ  Edit์„ ์„ ํƒํ•œ๋‹ค.

image-20240809-002932.png

Branch Policies - Require a minimum number of reviewers๋ฅผ โ€œ1โ€๋กœ ์„ค์ •ํ•˜๊ณ  ๋ฐ๋ชจ์˜ ํŽธ์˜์„ฑ์œผ ์œ„ํ•ดํ•ด Allow requestors to approve their own changes๋ฅผ ์ฒดํฌํ•œ๋‹ค.

image-20240809-004601.png

์ด์ œ ๋‹ค์‹œ Azure Repo > files๋กœ ์ด๋™ํ•˜์—ฌ master ๋ธŒ๋žœ์น˜์—์„œ colors.txt๋ฅผ ์„ ํƒํ•˜๊ณ  Edit์„ ์„ ํƒํ•œ๋‹ค. ํŒŒ์ผ ๋ณ€๊ฒฝ ํ›„ Commit์„ ์‹œ๋„ํ•˜๋ฉด โ€œTF402455: Pushes to this branch are not permitted; you must use a pull request to update this branch.โ€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, ์ด ๋ธŒ๋žœ์น˜์— ๋Œ€ํ•œ ํ‘ธ์‹œ๋Š” ํ—ˆ์šฉ๋˜์ง€ ์•Š์•˜์œผ๋ฉฐ ์ด ๋ธŒ๋žœ์น˜์˜ ์—…๋ฐ์ดํŠธ๋Š” Pull Request๋ฅผ ํ†ตํ•ด์„œ๋งŒ ๊ฐ€๋Šฅํ•จ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

image-20240809-005436.png

์ด์ œ ๊ตฌ์„ฑ๋œ ํ™˜๊ฒฝ์„ ํ† ๋Œ€๋กœ ์ฝ”๋“œ ๋ณ€๊ฒฝ ๋ฐ Pull Request๋ฅผ ํ†ตํ•œ master ๋ธŒ๋žœ์น˜๋กœ์˜ ๋ณ‘ํ•ฉ์„ ์‹œ๋„ํ•ด ๋ณด๊ฒ ๋‹ค.

ย 

ย 

Git ๋ธŒ๋žœ์น˜ ์ „๋žต ๊ตฌ์„ฑ ์ฆ

์†Œ์Šค ํ˜„ํ–‰ํ™”

ํ„ฐ๋ฏธ๋„๋กœ ์ด๋™ํ•˜์—ฌ ๋‹ค์Œ ๋ช…๋ น์„ ํ†ตํ•ด feature ๋ธŒ๋žœ์น˜๋กœ์˜ ์†Œ์Šค๋ฅผ ํ˜„ํ–‰ํ™” ํ•œ๋‹ค.

๋จผ์ € ํ˜„์žฌ ๋ธŒ๋žœ์น˜๋ฅผ ํ™•์ธํ•˜๊ณ  ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…์„ ์ค€๋น„ํ•œ๋‹ค.

git branch git checkout -b feat-1-colors git fetch --dry-run git pull origin master cat colors.txt git log --oneline --graph

ย 

ADO-git-handson# cd 20240808_git_handson/ ADO-git-handson# git branch feat-1-colors * master ADO-git-handson# git checkout feat-1-colors Switched to branch 'feat-1-colors' Your branch is up to date with 'origin/feat-1-colors'. ADO-git-handson# git fetch --dry-run Password for 'https://zerobig-devops4demo@dev.azure.com': remote: Azure Repos remote: Found 3 objects to send. (0 ms) Unpacking objects: 100% (3/3), 295 bytes | 5.00 KiB/s, done. From https://dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo 3e53445..28bab0f master -> origin/master ADO-git-handson# git pull origin master Password for 'https://zerobig-devops4demo@dev.azure.com': From https://dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo * branch master -> FETCH_HEAD Updating b5ecbfd..28bab0f Fast-forward colors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ADO-git-handson# cat colors.txt Red Green Blue Pink ADO-git-handson# git branch * feat-1-colors master ADO-git-handson# ADO-git-handson# git log --oneline --graph * 28bab0f (HEAD -> feat-1-colors, origin/master) Updated colors.txt * 3e53445 (master) Merged PR 57: Add colors.txt |\ | * b5ecbfd (origin/feat-1-colors) Add colors.txt |/ * 18c1fe6 First Commit ADO-git-handson#

ย 

์†Œ์Šค ์ˆ˜์ • ๋ฐ commit, push

colors.txt ํŒŒ์ผ์„ ์—ด์–ด Yellow๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์ €์žฅํ•œ ํ›„ git add, commit ๋ฐ push๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.

vi colors.txt git add . git commit -m "Update colors.txt adding color 'Yello'" git push

ย 

ADO-git-handson# vi colors.txt ADO-git-handson# cat colors.txt Red Green Blue Pink Yellow ADO-git-handson# git add . ADO-git-handson# git status On branch feat-1-colors Your branch is ahead of 'origin/feat-1-colors' by 2 commits. (use "git push" to publish your local commits) Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: colors.txt ADO-git-handson# git commit -m "Update colors.txt adding color 'Yello'" [feat-1-colors dc46381] Update colors.txt adding color 'Yello' 1 file changed, 2 insertions(+), 1 deletion(-) ADO-git-handson# git push Password for 'https://zerobig-devops4demo@dev.azure.com': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 8 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 326 bytes | 21.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Analyzing objects... (3/3) (6 ms) remote: Validating commits... (1/1) done (0 ms) remote: Storing packfile... done (29 ms) remote: Storing index... done (55 ms) To https://dev.azure.com/zerobig-devops4demo/202408_AzureDevOps_Git_Demo/_git/202408_AzureDevOps_Git_Demo b5ecbfd..dc46381 feat-1-colors -> feat-1-colors ADO-git-handson#

ย 

Pull Request ์ž‘์„ฑ

๋ฆฌ๋ชจํŠธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ƒˆ๋กœ๊ณ ์นจํ•˜์—ฌ ํ‘ธ์‹œ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•œ๋‹ค.

image-20240809-015134.png

Create a pull request๋ฅผ ์„ ํƒ ํ›„ Reviewers์— ์ž์‹ ์„ ์ถ”๊ฐ€ํ•˜๊ณ  Pull Request๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

image-20240809-015715.png
image-20240809-030049.png

์ •์ƒ์ ์œผ๋กœ master ๋ธŒ๋žœ์น˜์— ๋ณ‘ํ•ฉ์ด ์ด๋ฃจ์–ด์ง„ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image-20240809-025802.png

์ฐธ๊ณ ๋กœ Reviewers๋ฅผ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์‚ฌ์ „์— ๊ตฌ์„ฑํ•œ ๋ธŒ๋žœ์น˜ ์ •์ฑ…์œผ๋กœ ์ธํ•ด Pull Request ์ž‘์„ฑ์ด ๋ถˆ๊ฐ€ํ•จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image-20240809-015938.png

Pull Request ๊ฒ€ํ† ์ž๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๋น„๊ตํ•  ์ˆ˜๋„ ์žˆ๊ณ  ํ•„์š” ์‹œ, ์˜๊ฒฌ์„ ๋‚จ๊ธธ ์ˆ˜๋„ ์žˆ๋‹ค.

image-20240809-020814.png
image-20240809-020305.png
image-20240809-020917.png
image-20240809-021021.png

Repos > Commits๋ฅผ ์„ ํƒํ•˜์—ฌ ๋‘ ๋ธŒ๋žœ์น˜์˜ ๋‚ด์šฉ์„ ๋น„๊ตํ•˜์—ฌ ์‚ดํŽด๋ณธ๋‹ค.

master ๋ธŒ๋žœ์น˜์— Merged ์ปค๋ฐ‹์ด ์ถ”๊ฐ€๋˜์–ด ์žˆ์œผ๋ฉฐ ์ปค๋ฐ‹ ์ด๋ ฅ์ด ์ผ์น˜ํ•˜๊ณ  ์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

# master

image-20240809-025655.png

# feat-1-colors

image-20240809-025608.png

ย 

Related content