[๋ฉ๋ชจ] Git & Bash ํํ ๋ฆฌ์ผ
ํด๋น ๊ฒ์๊ธ์ ํจ์คํธ์บ ํผ์ค์์ ์งํํ๋
AI๋ถํธ์บ ํ ๊ต์ก๊ณผ์ ์ ํ ๋๋ก ์์ฑํ์ต๋๋ค.
1. ์(shell)
1.1 ๊ฐ์
์ด์์ฒด์ ์ ์ปค๋๊ณผ ์ฌ์ฉ์๋ฅผ ์ด์ด์ฃผ๋ ์ํํธ์จ์ด
1.1.1 ์ข ๋ฅ
- 01 sh(Bourne Shell)
- 02 csh
- 03 bash
- 04 zsh
1.2 ์ปค๋งจ๋
1.2.1 ํด๋๋ด ํ์ผํ์ธ
$ ls
์์ :$ ls
1.2.2 ๋๋ ํ ๋ฆฌ ์ด๋
$ cd ํด๋์ฃผ์
์์ :$ cd Document
1.2.3 ํด๋์์ฑ
$ mkdir ํด๋๋ช
์์ :$ mkdir dev
1.2.4 ํ์ผ์์ฑ(linuxํ๊ฒฝ : ubuntu, git bash)
$ touch ํ์ผ๋ช
์์ :$ touch sample.py
1.2.5 ํ์ผ์์ฑ(windowํ๊ฒฝ : powershell)
> New-Item ./ํ์ผ๋ช
์์ :New-Item ./sample.py
1.2.6 ํ์ผ์ด๋(ํน์ ํด๋๋ก)
$ mv ํ์ผ๋ช
ํด๋๋ช
/
์์ :$ mv sample.py dev/
1.2.7 ํ์ผ์ด๋(ํน์ ํด๋๋ก)
$ cp ๊ธฐ์กดํ์ผ๋ช
/ ๋ณต์ฌํ ํ์ผ๋ช
์์ :$ cp sample.py / sample_copy.py
1.2.8 ํ์ผ์ญ์
$ rm ํ์ผ๋ช
์์ :$ rm newfile.md
1.2.9 ํด๋์ญ์
$ rm -rf ํด๋๋ช
์์ :$ rm -rf temp
1.2.10 ํด๋์ญ์
$ rm ํ์ผ๋ช
์์ :$ rm newfile.md
1.2.11 ํ์ผ๋ด์ฉํ์ธ
$ cat ํ์ผ๋ช
์์ :$ cat README.md
2. ๋น(vim)
2.1 ๊ฐ์
Bill Joy์ vi ํ์ฅํ์ผ๋ก, CLI ๊ธฐ๋ฐ์ ํ ์คํธ ํธ์ง๊ธฐ์ด๋ค.
2.1.1 ๋ชจ๋์ข ๋ฅ
01 ์ผ๋ฐ๋ชจ๋(normal mode)
๋จ์ถํค : (ESC)
02 ํธ์ง๋ชจ๋(insert mode)
๋จ์ถํค : (i)
03 ๋ธ๋ก์ค์ (visual mode)
๋จ์ถํค : (v)
04 ์ก์
๋ชจ๋(command-line mode)
๋จ์ถํค : (:)
2.2 ์ปค๋งจ๋
2.2.1 ์ผ๋ฐ๋ชจ๋(normal mode)
h j k l - left, down, up, right
i - insert mode
v - visual mode
ESC - back to normal mode
d - delete
dd - delete a line
y - yank
yy - yank a line
p - paste
u - undo
a - append
A - append from end of line
o - open line(under)
O - open line(upper)
H - move to the top of the screen
L - move to the bottom of the screen
2.2.2 ์ก์ ๋ชจ๋(command-line mode)
:q - quit
:q! - override and quit
:w - write
:wq - write and quit
:{num} - Go to {num}th line
3. ๊น(git)
3.1 ๊ฐ์
๋ถ์ฐํ ๋ฒ์ ๊ด๋ฆฌ ์์คํ
3.2 ์ ๋ก๋/๋ค์ด๋ก๋ ์ํ๊ตฌ์กฐ
Tip! : ์์ ์ ๋๋๋ก์ด๋ฉด push ํ๊ธฐ์ ์ ํ ๊ฒ!,
pull ํ๋ค๋ ๊ฑด๋๋ฆฌ์ง ์๋๊ฒ ์ข๋ค
3.3 ์ด๊ธฐ์ค์
# ๊ฐํ๋ฌธ์ ์ค์ (Window=true, Mac=input)
$ git config --global core.autocrlf true
# ์ด๋ฆ ์ค์
$ git config --global user.name ์ฌ์ฉ์๋ช
# ์ด๋ฉ์ผ ์ค์
$ git config --global user.email ์ฌ์ฉ์์ด๋ฉ์ผ์ฃผ์
# ํ
์คํธ ์๋ํฐํด ์ค์
$ git config --global core.editor 'vim'
# ํ
์คํธ ํ์ธ์ฉํด ์ค์
$ git config --global core.pager 'cat'
3.4 ๊น์ฌ์ฉ ์์
3.4.1 CLI์ฉ (Linux๊ธฐ๋ฐ)
์์ | ๋ด์ฉ | ์ฝ์ ๋ช ๋ น์ด |
---|---|---|
1 | ๊น ๋ ํฌ์งํ ๋ฆฌ [์์ฑ] |
None |
2 | ๊น ๋ ํฌ์งํ ๋ฆฌ [ํด๋ก ] |
$ git clone ์ฃผ์ |
3 | .gitignore ์์ฑ๋ฐ์ค์ | https://www.toptal.com/developers/gitignore/ |
4 | pre-commit ์ค์ | (https://pre-commit.com/) |
5 | ํ์ผ์์ฑ[blob] |
$ touch ํ์ผ๋ช
|
6 | ํ์ผ ๋ก์ปฌ๋ฑ๋ก[tree] |
$ git add ํ์ผ๋ช
|
7 | ํ์ผ์ปค๋ฐ์ฐฝ ์ด๊ธฐ(vim) | $ git commit |
8 | vim์์ ์ปค๋ฐ๋ด์ญ์์ฑ | iํธ์ง-> ESC-> : wq๋ก ์ ์ฅ |
9 | ์๊ฒฉ ๋ ํฌ์งํ ๋ฆฌ์ [์
๋ก๋] |
$ git push origin ๋ธ๋์น๋ช
|
๊ฐ ๋จ์ ์์
๋ง๋ค 4~6๋ฒ ๋ฐ๋ณต
์๊ฒฉ ์
๋ก๋์ 7๋ฒ์ํ
๐ฅ์ฐจ์ด์ ์ ํ๊ดํ ํ์ํจ
3.4.2 vsCode์ฉ (Window๊ธฐ๋ฐ : powershell)
์์ | ๋ด์ฉ | ์ฝ์ ๋ช ๋ น์ด |
---|---|---|
1 | ๊น ๋ ํฌ์งํ ๋ฆฌ [์์ฑ] |
None |
2 | ๊น ๋ ํฌ์งํ ๋ฆฌ [ํด๋ก ] |
$ git clone ์ฃผ์ |
3 | .gitignore ์์ฑ๋ฐ์ค์ | https://www.toptal.com/developers/gitignore/ |
4 | pre-commit ์ค์ | (https://pre-commit.com/) |
5 | ํ์ผ์์ฑ | New-Item ./ํ์ผ๋ช |
6 | ํ์ผ ๋ก์ปฌ๋ฑ๋ก[tree] |
$ git add ํ์ผ๋ช
|
7 | ํ์ผ์ปค๋ฐ์ฐฝ ์ด๊ธฐ(vim) | $ git commit |
8 | vsCode์์ ์ปค๋ฐ๋ด์ญ์์ฑ | None |
9 | ์๊ฒฉ ๋ ํฌ์งํ ๋ฆฌ์ [์
๋ก๋] |
$ git push origin ๋ธ๋์น๋ช
|
๊ฐ ๋จ์ ์์
๋ง๋ค 4~6๋ฒ ๋ฐ๋ณต
์๊ฒฉ ์
๋ก๋์ 7๋ฒ์ํ
๐ฅ์ฐจ์ด์ ์ ํ๊ดํ ํ์ํจ
3.5 ์ปค๋ฐ ์ปจ๋ฒค์ ๊ท์น
3.5.1 ์์
{type} : ์ค๋ช
์์
๋จ์ ์ถ์ฝ
fix!: resolve issue with login page
{body} : ์์
์์ธ ๊ธฐ์
This commit fixes an issue with the login page that prevented users from logging in.
{footer} ๋ถ๊ฐ์ ๋ณด
BREAKING CHANGE: since current version, drop social login support
3.5.2 ๋ถ๋ฅ
๐ฅ feat: ๊ธฐ๋ฅ ๊ฐ๋ฐ ๊ด๋ จ
๐ง fix: ์ค๋ฅ ๊ฐ์ ํน์ ๋ฒ๊ทธ ํจ์น
๐จ docs: ๋ฌธ์ํ ์์
๐ฉ test: test ๊ด๋ จ
๐ฆ conf: ํ๊ฒฝ์ค์ ๊ด๋ จ
๐ช build: ๋น๋ ์์ ๊ด๋ จ
โฌ style: ์ฝ๋ ํฌ๋งคํ ๊ด๋ จ
3.6 ํ๋ฆฌ์ปค๋ฐ(Pre-commit)
3.6.1 ๊ฐ์
commit ์ํ ์ ์ฒดํฌํด์ผ ํ ๊ฒ๋ค์ ์๋ ์ํํ๋๋ก ๋์์ฃผ๋ ๋๊ตฌ
URL : https://pre-commit.com/
3.6.2 ์์
1 pre-commit์ค์น(์ ์ฒด ๋ผ์ด๋ธ๋ฌ๋ฆฌ์)
2 ๋ฒ์ ํ์ธ
3 .pre-commit-config.yaml ์์ฑ
4 pre-commit ์ค์น(ํ์ฌํ๋ก์ ํธ์)
5 pre-commit ์คํ
# ์ฝ๋
$ pip install pre-commit (or $ pip3 install pre-commit)
$ pre-commit --version
$ touch .pre-commit-config.yaml
# after setting configuration
$ pre-commit install
$ pre-commit run --all-files
3.7 ๋ธ๋์น
3.7.1 ๊ฐ์
๋ถ๊ธฐ์ ์ ์์ฑํ์ฌ ๋ ๋ฆฝ์ ์ผ๋ก ์ฝ๋๋ฅผ ๋ณ๊ฒฝํ ์ ์๋๋ก
๋์์ฃผ๋ ๋ชจ๋ธ