์๋ก (Introduction)
Git graph๋ฅผ ์ด์ฉํ์ฌ ๋ฒ์ ๊ด๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ๋ฐฐ์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. Source control์์ ๊ทธ๋ํ ๋ชจ์์ ๋ฒํผ์ ํด๋ฆญํ๊ฑฐ๋ window ํ๋จ์ 'Git Graph'์ ํด๋ฆญํ์ฌ Git graph์ ์ ๊ทผํ ์ ์์ต๋๋ค.ย
Let's learn how to manage versions using Git graph. You can access the Git graph by clicking on the button with a graph icon in the Source Control panel or by clicking on 'Git Graph' at the bottom of the window.
Git graph์ ์ ๊ทผํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ๋ฉด์ ํ์ธํ ์ ์์ต๋๋ค.
When accessing the Git graph, you will see the following screen.
Interface
๊ฐ ์์ญ์ ์ค๋ช ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1. ์ง๊ธ๊น์ง Pushํ commit๋ค ์๊ฐํํ์ฌ ๋ณด์ฌ์ค๋๋ค.
2. ํ์ฌ ๋ค๋ฃจ๊ณ ์๋ Commit๊ณผ ๊ทธ์ message๋ฅผ ๋ํ๋ ๋๋ค. ('Current branch'๋ผ๊ณ ํฉ๋๋ค.) (Check out์ผ๋ก ๋ค๋ฅธ Commit์ผ๋ก ์ด๋ํ ์ ์์ต๋๋ค. ๋ณธ ๊ฐ์์์๋ ๋ค๋ฃจ์ง ์์ต๋๋ค. )
3. ๊ฐ Commit์ด Push๋ ๋ ์ง์ Pushํ ์ฌ๋ ๊ทธ๋ฆฌ๊ณ Commit์ ๊ณ ์ ๋ฒํธ๋ฅผ ๋ํ๋ด์ค๋๋ค.
Here is an explanation of each section:
1. It visualizes the commits that have been pushed so far.
2. It represents the current commit being discussed along with its message. (It is referred to as the 'Current branch'.) (You can use "Check out" to move to a different commit, but we won't cover that in this tutorial.)
3. It displays the date and author of each pushed commit, along with a unique identifier for each commit.
๋ณ๊ฒฝ์ฌํญ ํ์ธ(Review of changes)
๋ณ๊ฒฝ์ฌํญ์ ํ์ธํ๊ณ ์ถ์ Commit์ ํด๋ฆญํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ๋ฉด์ ํ์ธํ ์ ์์ต๋๋ค. ํ์ผ๋ช ์ ์๊น์ ์๋ฏธ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
์ด๋ก์: ํ์ผ์ด ์๋ก ์์ฑ๋ ๊ฒฝ์ฐ
๋ ธ๋์: ๊ธฐ์กด์ ํ์ผ์ ์์ ํ ๊ฒฝ์ฐ
๋นจ๊ฐ์: ํ์ผ์ด ์ญ์ ๋ ๊ฒฝ์ฐ
When you click on a commit to review the changes, you will see the following screen. The colors of the file names have the following meanings:
Green: The file is newly created.
Yellow: The existing file has been modified.
Red: The file has been deleted.
๋ณ๊ฒฝ์ฌํญ์ ๋ ์์ธํ ํ์ธํ๊ณ ์ถ์ ๊ฒฝ์ฐ Commit์ ํด๋ฆญํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ํ๋ฉด์ ํ์ธํ ์ ์์ต๋๋ค.ย
์ผ์ชฝ์ ๋ณ๊ฒฝ ์ ์ ๋ด์ฉ์ด๊ณ , ์ค๋ฅธ์ชฝ์ ๋ณ๊ฒฝ ํ์ย ๋ด์ฉ์ ๋๋ค.
์๋ฅผ ๋ค์ด, 'revised file.txt'๋ฅผ ํด๋ฆญํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด 'Also, I like dogs'๋ผ๋ ๋ฌธ์ฅ์ด ์ถ๊ฐ๋์์์ ์์๋ผ ์ ์์ต๋๋ค.ย
If you want to examine the changes in more detail, you can click on a commit, and you will see the following screen. The left side shows the content before the changes, and the right side shows the content after the changes.
For example, if you click on 'revised file.txt', you will see that the sentence 'Also, I like dogs' has been added, indicating the specific change made.
์๋ ๋ฒ์ ์ผ๋ก ๋์๊ฐ๊ธฐ(To reset to an old version)
Commit๋ค ๊ฐ์ ์ด๋์ ์๋ฏผํ๊ณ ๋ณต์กํ๋ฏ๋ก, ์๋ ๋ฒ์ ์ผ๋ก ๋์๊ฐ๊ธฐ ์ ์๋ ์ค๋ฅธ์ชฝ์ ํ๋ฉด์ฒ๋ผ Source control์์ ๋ณ๊ฒฝ ์ฌํญ์ด ์๋ ์ํ์์ ์งํํ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค.
๋ง์ฝ ์ฝ๋๋ฅผ ๊ณต์ ํ๊ณ ์๋ ๊ฒฝ์ฐ 'reset'์ด ์๋๋ผ 'revert'๋ฅผ ์ถ์ฒํฉ๋๋ค. ๋ํ 'branch'๋ฅผ ์ถ์ฒํฉ๋๋ค. ํ์ง๋ง ๋ณธ ๊ฐ์์์๋ ๋ค๋ฃจ์ง ์์ต๋๋ค.
Moving between commits can be sensitive and complex. Therefore, before reverting to an old version, it is recommended to proceed from a clean state in Source Control, as shown on the right-hand side of the screen, with no pending changes.
If you are sharing your code with others, it is recommended to use 'revert' instead of 'reset'. Alternatively, using 'branch' is also recommended. However, we won't cover these topics in this tutorial.
1. ๋์๊ฐ๊ณ ์ถ์ ๋ฒ์ ์ commit์ ์ค๋ฅธ์ชฝ ํด๋ฆญํ๊ณ , 'Resetย current branch to this commit'์ ํด๋ฆญํ์ธ์.
2. ๊ทธ๋ฌ๋ฉด ์ค๋ฅธ์ชฝ ํ๋ฉด์ ํ์ธํ ์ ์์ต๋๋ค. ์ธ ๊ฐ์ง ์ต์ ์ค์ ํ๋๋ฅผ ์ ํํ ์ ์๊ณ , ๊ฐ ์ต์ ์ ์ค๋ช ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.ย
Soft: ๋ณ๊ฒฝ ์ด๋ ฅ์ ๋ชจ๋ ์ญ์ ํ์ง๋ง ์ ํํ ๊ณผ๊ฑฐ์ Commit๊ณผ ํ์ฌ์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ชจ๋ ๋ฐ์๋ค์ ๋๋ค.
Mixed: ๋ณ๊ฒฝ ์ด๋ ฅ์ ๋ชจ๋ ์ญ์ ํ์ง๋ง ๋ณ๊ฒฝ ๋ด์ฉ์ ๋จ๊ธฐ๊ณ ์ ํํ ๊ณผ๊ฑฐ์ Commit์ ๋ฐ์๋ค์ ๋๋ค.
Hard: ๋ณ๊ฒฝ ์ฌํญ์ ๋ชจ๋ ์ญ์ ํ๊ณ ์ ํํ ๊ณผ๊ฑฐ์ Commit๋ง ๋ฐ์๋ค์ ๋๋ค.ย
1. Right-click on the commit of the version you want to revert to, and click on "Reset current branch to this commit."
2. You will then see the right-hand side screen. You can choose one of the three options, and here are the explanations for each option:
Soft: All commit history will be removed, but both the selected past commit and the current changes will be kept.
Mixed: All commit history will be removed, but the changes will be kept, accepting the selected past commit.
Hard: All changes will be discarded, and only the selected past commit will be accepted.
3. ์ ํํ ์ต์ ์ ๋ฐ๋ผ์ ์ต์ฐ์ ์ ์ผ๋ก Push๋ฅผ ์ฑ๊ณต์ํจ ํ์ ์์ ์ ์ด์ด๋๊ฐ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค.
Version Control์ ๊ณผ์ ์ด ๋ณต์กํ๊ธฐ ๋๋ฌธ์ ์ฒ์์๋ ์ ์คํ Hard ์ต์ ๋ง์ ์ฌ์ฉํ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค.ย
๋ณด๋ค ์์ธํ ๋ด์ฉ์ ์๋ ๋งํฌ์ ์๋ฃ๋ค์ ์ฐธ๊ณ ํ์ธ์.
3. It is recommended to prioritize successful pushes based on the chosen option before continuing with your work.ย
Since Version Control can be complex, it is advisable to start with cautious use of the "Hard" option. For more detailed information, please refer to the resources available at the links below.