Git & Github ์ค๋ฌด ํ์ฉ ์๋ฒฝ ๊ฐ์ด๋ part1. (Git ๊ธฐ์ด ๋ฐ ์ปค๋ฐ)
๋์ปค ๊ฐ์์ ํจ๊ป ์ ์ฒญํ ์ ๋ฐ๋ฏธ ๊ฐ์, Git & Github ์ค๋ฌด ํ์ฉ ์๋ฒฝ ๊ฐ์ด๋
์ด์ ์ ๊น๊ณผ ๊นํ์ ๊ฑฐ์ ์ฌ์ฉํ์ง ์์ ๊น์ด๋ ๊นํ์ ์ฌ์ฉํ ์ค ์๋ ๊ฑด ๋ ํฌ ๋ง๋ค๊ณ ํ์ผ๋ค ์ฌ๋ฆฌ๊ณ ๊น ํด๋ก ํ๋ ๊ฒ ์ ๋ถ์๋ค... ๊ทธ๋ฌ๋ ๊น, ๊นํ์ ์ฌ์ฉํ์ฌ ํ์ ํ๋ ๊ณณ์ด ์ ๋ง ๋ง์ผ๋ฏ๋ก ์ด๋ฒ ๊ธฐํ์ ๊ธฐ๋ณธ์ ๋ฐฐ์๋ณด๊ณ ์ ์ด ๊ฐ์๋ฅผ ์ ํํ์๋ค.
๊ฐ์์ ๋ด์ฉ๋ค์ด ์น์ ๋ณ๋ก ์๊ฒ ์ชผ๊ฐ์ ธ ์์ด ํ๋ ํ์ด์ง์ ๊ธ๋ก ๋ด์ฉ๋ค์ ์ ๋ฆฌํ ์ ์์ ๊ฒ ๊ฐ๋ค.
์น์ 2 : Git ์๊ฐ
Git์ด๋?
- ๊น์ ์ ์ธ๊ณ์์ ๋๋ฆฌ ์ฌ์ฉ๋๊ณ ์๋ ๋ฒ์ ๊ด๋ฆฌ ์์คํ ์ผ๋ก, ํ๋ ฅ๊ณผ ๋ณํ์ ๊ณต์ ๊ฐ ์ฃผ ํน์ง์ด๋ค. ์ฌ์ฉ์์ ๊ฐ๋ฐ์, ์์ฑ์ ๊ฐ์ ํ๋ ฅ์ ๊ฐ๋ฅํ๊ฒ ํ๊ณ ๋๊ตฌ๋ ๊น์ผ๋ก ์์ ํ๋ ์ฌ๋๋ค์ด ๊ฐ ๊ฐ์ธ๋ค ๊ฐ์ ๋ฒ์ด์ง๋ ์ฌ๋ฌ ๋ณํ์ ์์ ์ฌํญ๋ค์ ์๋ก ๊ณต์ ํ ์ ์๋๋ก ๋์์ค๋ค.
- ๊น์ ์ฒดํฌํฌ์ธํธ ์ค์ ์ด ๊ฐ๋ฅํ๋๋ก ํด์ค๋ค. ์์ ์ ์ค๊ฐ์ค๊ฐ๋ง๋ค ์ฒดํฌํฌ์ธํธ๋ฅผ ๋๊ณ ๋ฒ์ ์ ์ค์ ํ์ฌ ์ํ๋ ์์ ์ผ๋ก ๋กค๋ฐฑํ๊ฑฐ๋ ์ด๋ํ๊ฑฐ๋ ํน์ ํ ์ฒดํฌํฌ์ธํธ์์ ๋ค๋ฅธ ๋ฐฉํฅ์ผ๋ก ๊ฐ๋ฐ๋ ๊ฐ๋ฅํ๊ฒ ํ๋ค. ํน์ ์ฒดํฌํฌ์ธํธ๋ค์ ๊ฒฐํฉํ๊ธฐ๋ ํ๋ค.
Git vs Github
- Git ≠ Github
- Git
- ๋ฒ์ ผ ๊ด๋ฆฌ ์ํํธ์จ์ด. ์ปดํจํฐ์์ ์คํ๋๋ฉฐ ์ธํฐ๋ท์ด๋ ๊ณ์ ๋ฑ๋ก์ด ํ์๊ฐ ์๋๋ค. MS Word๋ Excel ๊ฐ์ ๋ฌธ์ ํ๋ก๊ทธ๋จ์ฒ๋ผ ๊ทธ์ ์ฌ์ฉํ๋ ์ผ์ข ์ ํ๋ก๊ทธ๋จ์ด๋ค.
- Github
- ์น์๋น์ค. ๊น ํ๋ธ๋ ๊น ์ ์ฅ์๊ฐ ํ์ํ๋ฉฐ ํด๋ผ์ฐ๋์ ์์ค ์ฝ๋๋ค์ ์ ์ฅํด์ ๋ค๋ฅธ ์ฌ๋๊ณผ ์ฝ๊ฒ ๊ณต๋์ผ๋ก ์์ ํ ์ ์๋๋ก ํด์ค๋ค. ์น์ฌ์ดํธ ๊ธฐ ๋๋ฌธ์ ๊ณ์ ๊ณผ ์ธํฐ๋ท์ด ํ์ํ๋ค.
- ๊น์ ์ฌ์ฉํด ๋ด๊ฐ ์์ ํ ๋ด์ฉ๋ค์ ๊นํ๋ธ์ ์ ๋ก๋ํ์ฌ ๊ณต์ ๋ฐ ๊ฒ์ํ ์ ์์ผ๋ฉฐ ๋ค๋ฅธ ์ฌ๋๋ค์ ์ด ์ฝ๋์ ๊นํ๋ก์ ํธ๋ฅผ ๊ฐ์์ ์ปดํจํฐ๋ก ๊ฐ์ ธ๊ฐ ์ ์๋ค.
์น์ 3 : ์ค์น ๋ฐ ์ค์
Git ์ค์น ๋ฐ ์ค์ ํ๊ธฐ
- ์ฃผ ์ฌ์ฉํ๊ฒฝ์ ์๋์ฐ๋ฏ๋ก ์๋์ฐ๋ฅผ ๊ธฐ์ค์ผ๋ก ์งํํ์๋ค. ์ค์น ํ์ด์ง์์ ๋ง๋ ๋นํธ์ ์๋์ฐ ๋ฒ์ ์ ๋ค์ด๋ก๋ํ์ฌ ์ค์นํด์ฃผ๋ฉด ๋.
- ์ค์น ํ์ Git ์ด๋ฆ๊ณผ ์ด๋ฉ์ผ์ ๋จผ์ ์ค์ ํด์ค์ผํ๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config user.name
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config --global user.name "bh lee"
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config user.name
bh lee
---
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config user.email
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config --global user.email "lbh1224@gmail.com"
userpc@DESKTOP-UQ5OHLV MINGW64 ~
$ git config user.email
lbh1224@gmail.com
์น์ 4 : Git์ ๊ธฐ์ด.
+์น์ 5 : ์ปค๋ฐ๊ณผ ๊ด๋ จ ์ฃผ์ ์์ธํ๊ฒ ์์๋ณด๊ธฐ
์น์ 4์ ์น์ 5, ๋ ์น์ ์ ์ปค๋ฐ์ ๋ํด ๋ด์ฉ์ ๋ค๋ฃจ๋ฏ๋ก ํจ๊ป ์ ๋ฆฌํ์๋ค.
Git Repo ๋ง๋ค๊ธฐ
- ๊น์ ์ฌ์ฉํ๊ธฐ ์ ์ ๋จผ์ ๋ ํฌ๋ผ ํํ ๋ถ๋ฅด๋ Repository๋ฅผ ๋ง๋ค์ด์ค์ผ ํ๋ค.
- ์ธ์ , ์ด๋ ๋๋ ํ ๋ฆฌ์ ์ ์ฅ์๋ฅผ ๋ง๋ค์ด์ผ ํ๋์ง ๊น์๊ฒ ์๋์ผ๋ก ์ง์ํด์ฃผ๋ ๊ฒ์ผ๋ก ์ ์ฅ์๋ค, ๋ชจ๋ ๋ ํฌ๋ค์ ๊ณ ์ ์ด๋ ฅ์ ๊ฐ๊ณ ์์ผ๋ฉฐ ์๋ก ๊ด๋ จ์ด ์๋ ๋ ๋ฆฝ์ ์ธ ์ฑ๊ฒฉ์ ๊ฐ๊ณ ์๋ค.
- ๊น์ ์ฌ์ฉํ๊ณ ์ถ๋ค๋ฉด ๊ฐ๊ฐ์ ํ๋ก์ ํธ ํด๋๋ก ์ด๋ํด์ ๊น ์ ์ฅ์๋ฅผ ์์ฑํ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
Git Init & Git Status
git status
- ํ์ฌ ์์นํ ๋ ํฌ์ ์ํ๋ฅผ ๋ณด๊ณ ํด์ฃผ๋ ๋ช ๋ น์ด.
- ๋ ํฌ๊ฐ ์์ง ์๋ค๋ฉด ์๋์ฒ๋ผ not a git repository, ๊น ์ ์ฅ์ ์ ๋ณด๊ฐ ์๋ค๊ณ ๋ฌ๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads
$ git status
fatal: not a git repository (or any of the parent directories): .git
git init
- ์ ๋ ํฌ์ ํ์ผ๋ก ์ค์ ํ๋ ๋ช ๋ น์ด. ํ์ฌ ์์นํ ๋๋ ํ ๋ฆฌ๋ฅผ ์๋ก์ด ๊น ์ ์ฅ์๋ก ์ค์ฒดํํ๋ค. ์ด ๋ช ๋ น์ด๋ ๋ ํฌ๋ฅผ ๋ง๋ค๋ ์ต์ด์๋ง ์ฌ์ฉํ๋ค.
- git init ๋ช ๋ น์ด๋ฅผ ํตํด ๋น ๊น ์ ์ฅ์๋ฅผ ์์ฑํ๊ฑฐ๋ ๊ธฐ์กด ์ ์ฅ์๋ฅผ ๋ค์ ์ด๊ธฐํํ ์ ์๋ค. ๋น ๊น ์ ์ฅ์๋ฅผ ์์ฑํ ๋ .git ์ด๋ผ๋ ์จ๊ฒจ์ง ํ์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ๋ค.
- ๊น ๋๋ ํ ๋ฆฌ๊ฐ .git ์ด๋ ๊ฒ ์จ๊ฒจ์ง ํํ์ธ ์ด์ ๋ ๋ง์ฝ ์ด๋ ฅ์ด ์๋ ๋๋ ํ ๋ฆฌ๋ฅผ ์ญ์ ํ๊ฒ ๋๋ค๋ฉด ๋ชจ๋ ์๋ฃ๋ค์ ์์ด๋ฒ๋ฆด ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
- ์์์ ์ธ๊ธํ๋ฏ์ด git init์ ์๋ก์ด ๊น ์ ์ฅ์๋ฅผ ๋ง๋ฌ๊ณผ ๋์์ ๊ธฐ์กด์ ์ ์ฅ์๋ฅผ ์ด๊ธฐํํ๊ธฐ ๋๋ฌธ์ ์ฌ๋ฌ๊ฐ์ ํ๋ก์ ํธ๋ฅผ ๊ด๋ฆฌํ ๋ ํญ์ git status๋ฅผ ์คํํด์ ๋จผ์ ํ์ธํ๋ ๊ฒ์ด ์ค์ํ๋ค. .git ํด๋๋ฅผ ์ญ์ ํ๋ ๊ฒ์ ์ ์ฅ์๋ฅผ ์ด๊ธฐํํ๋ ๊ฒ๊ณผ ๋์ผํ๋ค.
git init
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test
$ git init
Initialized empty Git repository in C:/Users/userpc/Downloads/git_study/test/.git/
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
.git directory
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ ls
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ ls -a
./ ../ .git/
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ cd .git/
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test/.git (GIT_DIR!)
$ ls
HEAD config description hooks/ info/ objects/ refs/
Git Add & Commit
- ์ปค๋ฐ ์ํฌํ๋ก์ฐ ๊ฐ์
- ๊น ์ปค๋ฐ์ ๊น ๋ ํฌ์ ์๋ ์ฒดํฌํฌ์ธํธ๋ค ์ค ํ๋๋ก ๋ณดํต ํ๋์ ์ ์ฅ์์ ์ด๋งํ๊ฒ ๋ง์ ์ปค๋ฐ๋ค์ด ์กด์ฌํ๋ค. ์์ฃผ ์ค์ํ ์ ์ ์ปค๋ฐ์ ํ์ผ์ ์ ์ฅํ๋ ๊ฒ๊ณผ ๊ฐ์ ๊ฒ์ด ์๋๋ผ๋ ์ ์ด๋ค. ํ์ผ์ ์ ์ฅํ๋ ๊ฒ ์ด์์ผ๋ก ์ด๋ค ๊ฒ์ ๊ตฌ์ถํ๋ค๋ ์๋ฏธ์ด๋ค.
- ์ปค๋ฐํ๊ธฐ ์ ์ ๋จผ์ ์์ ํด์ ํ์ผ์ ์ ์ฅํด์ผ ํ๋ฉฐ, ์๋์ ์ฌ์ง ์์ ์ฒ๋ผ ๋ณ๊ฒฝ์ฌํญ์ด ์์ผ๋ฉด ๊ทธ๊ฒ๋ค์ ๋ฌถ์ด์ ์ปค๋ฐํ ์ ์๋ค.
- ์ํฌ ํ๋ก์ฐ์๋ 3๊ฐ์ง ์์ญ์ด ์๋ค.
- ์ํน ๋๋ ํ ๋ฆฌ : ํ๋ก์ ํธ์์ ์ค์ ๋ก ์์ ํ๋ ๊ณต๊ฐ, ๋๋ ํ ๋ฆฌ.
- ์คํ ์ด์ง ์์ญ : ์ปค๋ฐํ๊ธฐ ์ ์ ๋ณ๊ฒฝ์ฌํญ๋ค์ ๋ฑ๋กํ๋ ๊ณณ
- ์ ์ฅ์ : .git ํด๋. ์ปค๋ฐ์ ํ๊ฒ ๋๋ฉด git commit์ .git ์์ ์๋ ๊ฒ๋ค์ ๋ณ๊ฒฝํ์ฌ ์ ์ปค๋ฐ์ ํด๋์ ๋ฑ๋กํ๋ค. ๊ทธ๋์ ์ปค๋ฐํ๋ฉด ๊ทธ ํด๋, ์ฌ์ค์ ๊น ์ ์ฅ์๋ฅผ ์ ๋ฐ์ดํธ ํ๋ ๊ฒ์ด๋ค.
- Git add๋ก ๋ณ๊ฒฝ์ฌํญ ์คํ
์ด์งํ๊ธฐ
- ์ด๋ค ์์ ์ ํ๊ณ ๋์ ์๊ธด ๋ณ๊ฒฝ์ฌํญ์ ์ปค๋ฐํ๊ธฐ ์ ์ ๋จผ์ add ๋ช ๋ น์ด๋ฅผ ํตํด ์คํ ์ด์ง์ ์ฌ๋ฆฌ๋ ๋จ๊ณ๋ฅผ ๊ฑฐ์ณ์ผ ํ๋ค.
๊ฐ๋จํ ์์ ๋ก git init์ ํตํด ์๋ก์ด ๋ ํฌ๋ฅผ ๋ง๋ค๊ณ characters.txt, outline.txt ๋ ๊ฐ์ ํ ์คํธ ํ์ผ์ ๋ง๋ ๋ค์ git staus๋ฅผ ์ณ๋ณด๋ฉด ์๋์ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋์จ๋ค.
๊น์ 2๊ฐ์ ํ์ผ์ ์ธ์ํ๊ณ ์์ง๋ง ์ถ์ ํ๊ณ ์์ง ์๋ค๊ณ ๋ณด์ฌ์ค๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
characters.txt
outline.txt
nothing added to commit but untracked files present (use "git add" to track)
git add๋ฅผ ์ด์ฉํด ๋ ํ ์คํธํ์ผ์ add ํ๋ฉด
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: characters.txt
new file: outline.txt
์ปค๋ฐํ๊ธฐ ์ , ์คํ ์ด์ง์ ์ฌ๋ผ๊ฐ ์๋ ์ํ๊ฐ ๋๋ค.
Git ์ปค๋ฐ ๋ฉ์ธ์ง
- ๊น์ ์ปค๋ฐํ ๋๋ ์ปค๋ฐ ๋ฉ์ธ์ง๋ฅผ ๊ฐ์ด ์ ์ ์ ์๋ค. ์ปค๋ฐํ ๋๋ง๋ค ๋ณ๊ฒฝ์ฌํญ์ ์์ฝํ๊ฑฐ๋ ๋ฌ์ฌํ๋ ๋ฉ์ธ์ง๋ฅผ ํฌํจํ๋ ๊ฒ์ด ์ข๋ค.
- git commit -m “my message”
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git commit -m "start work on outline and main characters"
[master (root-commit) fb4ec81] start work on outline and main characters
2 files changed, 2 insertions(+)
create mode 100644 characters.txt
create mode 100644 outline.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
nothing to commit, working tree clean
git status๋ฅผ ์คํํ๋ฉด ์ ์์ ์ผ๋ก ์ปค๋ฐ์ด ์ฒ๋ฆฌ๋์๋ค๊ณ ๋ฌ๋ค.
์ปค๋ฐํ ๋ ๋ฉ์ธ์ง๋ฅผ ์ ๊ณตํ๊ธฐ ์ํด git commit -m ๋ช ๋ น์ ์ฌ์ฉํ ๊ฒ์ ์ถ์ฒํ๋ค. ๋ง์ฝ git commit ๋ช ๋ น์ ์ฌ์ฉํ์ ๋ ๋ง์ฝ ์๋ํฐ๊ฐ ์ค์ ๋์ง ์์๋ค๋ฉด ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์๋ ์๋ค.
์์ ์์๋ ์ปค๋ฐ ๋ฉ์ธ์ง์ ๊ฐ๋จํ๊ฒ ํ ์ค๋ก ์ ์์ผ๋ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ์ฌ๋ฌ ์ค์ ์ปค๋ฐ๋ฉ์ธ์ง๋ฅผ ํตํด ์์ ์ ๋ํด ์์ธํ ์ค๋ช ์ด ํ์ํ ๊ฒฝ์ฐ๋ ์กด์ฌํ๋ค.
์์ ํ์ ์ปค๋ฐํ ๋ ์ปค๋ฐ ๋ฉ์ธ์ง๋ฅผ ๋ฐ๋ก ์์ฑํ์ง ์์ผ๋ฉด vim ์๋ํฐ๋ก ์ปค๋ฐ๋ฉ์ธ์ง๋ฅผ ์ ์ผ๋ผ๊ณ ์ฐฝ์ด ๋จ๊ฑฐ๋ ํน์ VSCode๋ฅผ ์ฌ์ฉํ๋ค๋ฉด VSCode๋ก ๋์ด๊ฐ๊ธฐ๋ ํ๋ค.
๋ง์ฝ ์ปค๋ฐ ๋ฉ์ธ์ง ํ ์คํธ ์๋ํฐ๊ฐ vim์ผ๋ก ๋ฐ ๊ฒฝ์ฐ git config --global core.editor “code --wait” ํด๋น ๋ช ๋ น์ด๋ฅผ ํตํด VSCode๋ก ํ ์คํธ ์๋ํฐ๋ฅผ ์ค์ ํด ์ค ์ ์๋ค.
Git Log ๋ช ๋ น์ด
# master ๋ธ๋์น์์ chapter1.txt ํ์ผ ์๋ก ์์ฑ
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ touch chapter1.txt
# git status๋ฅผ ํตํด ๋ณ๊ฒฝ์ฌํญ ํ์ธ
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
chapter1.txt
nothing added to commit but untracked files present (use "git add" to track)
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ ls
chapter1.txt characters.txt outline.txt
# characters.txt ํ์ผ ์์
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ vim characters.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: characters.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
chapter1.txt
no changes added to commit (use "git add" and/or "git commit -a")
๊ฐ๋จํ ์์ ๋ก ์๋ก์ด ํ ์คํธ ํ์ผ chapter1.txt๋ฅผ ์์ฑํ๊ณ characters.txt ํ์ผ์ ์์ ํ์๋๋ git status์์ ์์ ๊ฐ์ด ๋ณ๊ฒฝ์ฌํญ์ด ๋ฌ๋ค.
๋ณ๊ฒฝ์ฌํญ์ด ์๋ ๋ ํ์ผ, chapter1.txt characters.txt๋ฅผ add๋ฅผ ํตํด ์คํ ์ด์ง์ ์ฌ๋ฆฌ๊ณ ์ปค๋ฐ ๋ฉ์ธ์ง์ ํจ๊ป ์ปค๋ฐํ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git add chapter1.txt characters.txt
warning: in the working copy of 'characters.txt', LF will be replaced by CRLF the next time Git touches it
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: chapter1.txt
modified: characters.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git commit -m "begin work on chapter 1"
[master 6298419] begin work on chapter 1
2 files changed, 1 insertion(+)
create mode 100644 chapter1.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
nothing to commit, working tree clean
์ด์ธ์๋ ์๋ก์ด ํ์ผ์ ๋ง๋ค๊ฑฐ๋ ์์ ํ์ ๊ฒฝ์ฐ ๋ชจ๋ ๋ณ๊ฒฝ์ฌํญ์ git status์์ ํ์ธํ ์ ์์ผ๋ฉฐ ์ปค๋ฐ์ ํ์ ๋์ ๋ก๊ทธ๋ค๋ ์๋์ฒ๋ผ ํ์ธํ ์ ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git log
commit 00f2743ebeed35508a877d9f36de420a3dd9807d (HEAD -> master)
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:08:01 2024 +0900
split chapter 1 into two pieces
commit 5d2cd9756a67805b1a744e0a76ca050eeb1981ff
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:04:49 2024 +0900
finish chapter 1
commit 6298419754009b8490fbf80356fd905c9e960ea0
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:01:32 2024 +0900
begin work on chapter 1
commit fb4ec81f80ae6fa22f94e59bc28abd81984a2d36
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 18:49:23 2024 +0900
start work on outline and main characters
์ปค๋ฐ ๋ด์ญ์ด ์ ๋ค๋ฉด ์ด๋ ๊ฒ ๋ชจ๋ ๋ก๊ทธ๋ฅผ ์ถ๋ ฅํด๋ ๊ด์ฐฎ์ผ๋ ๋๋ถ๋ถ์ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ์ด๋ง์ด๋งํ ์ปค๋ฐ๋ค์ด ์กด์ฌํ๋ฏ๋ก ๋ชจ๋ ์ปค๋ฐ ๋ก๊ทธ๋ค์ ์ถ๋ ฅํ๋ค๋ฉด ๊ฐ๋ ์ฑ์ด ๊ต์ฅํ ์ ์ข์์ง๋ค. ๋ฐ๋ผ์ ์ด๋ฐ ๊ฒฝ์ฐ ์ถ์ฝ, ์์ฝํด์ฃผ๋ git log ์ต์ ๋ค์ ์ฌ์ฉํด ์ฃผ๋ฉด ์ข๋ค.
๊น ๋ก๊ทธ ๊ณต์๋ฌธ์์ ๋ชจ๋ ์ต์ ์ ์ ํ์๋ ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git log
commit a9533bf022b95ff74f79488e85c72818f2dcee80 (HEAD -> master)
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 28 20:41:42 2024 +0900
in outline, i add some sentence
this is example, commit message
addjdjdjdjdjdjdj
commit 1c0b4a341d9d5bcfeca8a930ccc9d752e8c98b2d
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 28 20:33:04 2024 +0900
Fix Typo in outline
commit 00f2743ebeed35508a877d9f36de420a3dd9807d
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:08:01 2024 +0900
split chapter 1 into two pieces
commit 5d2cd9756a67805b1a744e0a76ca050eeb1981ff
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:04:49 2024 +0900
finish chapter 1
commit 6298419754009b8490fbf80356fd905c9e960ea0
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 19:01:32 2024 +0900
begin work on chapter 1
commit fb4ec81f80ae6fa22f94e59bc28abd81984a2d36
Author: lbh1224 <leehag1224@gmail.com>
Date: Thu Mar 21 18:49:23 2024 +0900
start work on outline and main characters
-------------------------------after--------------------------------
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git log --oneline
a9533bf (HEAD -> master) in outline, i add some sentence this is example, commit message addjdjdjdjdjdjdj
1c0b4a3 Fix Typo in outline
00f2743 split chapter 1 into two pieces
5d2cd97 finish chapter 1
6298419 begin work on chapter 1
fb4ec81 start work on outline and main characters
์ด๋ ๊ฒ ์ถ์ฝ, ์์ฝํด์ ๋ก๊ทธ๋ฅผ ๋ณด๋ ๊ฒฝ์ฐ๊ฐ ์์ผ๋ฏ๋ก ์ปค๋ฐ ๋ฉ์ธ์ง์ ์ฒซ ๋ฒ์งธ ์ค์ ์๋ฌด๋ฆฌ ๊ธธ๋๋ผ๋ ์ปค๋ฐ ๋ด์ฉ์ ์์ฝํด์ผ ํ๋ค. ์ฒซ ๋ฒ์งธ ๋ผ์ธ์ ์ปค๋ฐ์ ์์ฝํ๋ค๋ ํจํด์ ๊ด๋ก์ด๋ค.
.gitignore
- ํ๋ก์ ํธ์์ ์์ ํ๋ฉด์ ๊น์ ์ฌ์ฉํ ๋, ๊ฐ๊ณ ์๋ ํ์ผ์ด๋ ๋๋ ํ ๋ฆฌ๊ฐ ๊น์๊ฒ ์๋ ค์ง๊ฑฐ๋ ์ถ์ ๋์ง ์๊ณ ์๋ฒฝํ ์ ์ธ๋๋ ๊ฒ์ด ํ์ํ ๊ฒฝ์ฐ๊ฐ ์๋ค.
- API ํค, ํจ์ค์๋, ํ ํฐ ๋ฑ ๋ณด์์ด ํ์ํ์ฌ ๊ณต์ ๋์ด์ ์ ๋๋ ๊ฒฝ์ฐ๋ ๊น์ ์ฌ๋ฆด ํ์ ์๊ณ ์ ์ธํด์ผ ํ๋ ๋ถํ์ํ ๊ฒฝ์ฐ๊ฐ ์กด์ฌํ๋ค. ์ด ๋ .gitignore ํ์ผ์ ๋ง๋ค๊ณ ์ํ๋ ๋ด์ฉ๋ค์ ๋ฆฌ์คํธ๋ก ์์ฑํ ์ ์๋ค.
๊ฐ๋จํ ์์ ๋ฅผ ํตํด ์ค๋ช ํด ๋ณด์๋ฉด
1. secrets.txt๋ผ๋ ๋ณด์์์ ๋ด์ฉ์ ๋ด๊ณ ์๋ ํ ์คํธ ํ์ผ์ด ์๋ค. ํด๋น ํ์ผ์ ๊น์ ์ํด ์ถ์ ๋์ด์๋, ์ปค๋ฐ๋์ด ๊ณต์ ๋์ด์๋ ์๋๋ค. ํ์ง๋ง ์์ง๊น์ง๋ ๊น์ ์ถ์ ์ ๋ฐ๊ณ ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ vim secrets.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
secrets.txt
nothing added to commit but untracked files present (use "git add" to track)
2. .gitignore ํ์ผ์ ๋ง๋ค์ด ๋ฆฌ์คํธ์ secrets.txt ํ์ผ์ ์ถ๊ฐํ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ touch .gitignore
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ ls -a
./ .git/ chapter1.txt characters.txt secrets.txt
../ .gitignore chapter2.txt outline.txt
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ vim .gitignore
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
์์ ๋ฌ๋ฆฌ git status์์ secrets.txt ํ์ผ์ด ๋ ์ด์ ๊น์ ์ถ์ ๋์ง ์์์ ํ์ธํ ์ ์๋ค.
ํ์ง๋ง .gitignore ํ์ผ ์์ฒด๊ฐ ์ถ์ ๋๊ณ ์๋ค. .gitignore ํ์ผ์ ํ์ฌ๋ก์ ์ปค๋ฐ๋ ํ์๊ฐ ์๋ ํ์ผ์ด๋ฏ๋ก ์ด ํ์ผ๋ ์ ์ธ๊ฐ ํ์ํ๋ค.
3. gitignore ํ์ผ์ ์๊ธฐ ์์ ๋ ๋ฆฌ์คํธ์ ์ถ๊ฐํ์๋ค.
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ vim .gitignore
userpc@DESKTOP-UQ5OHLV MINGW64 ~/Downloads/git_study/test (master)
$ git status
On branch master
nothing to commit, working tree clean
์ด์ ๋์ด์ ๊น์ ์ถ์ ์ ๋ฐ์ง ์๋ ๊ฒ์ ๋ณผ ์ ์๋ค.