Git์ ๋ถ์ฐํ๋ฒ์ ๊ด๋ฆฌ์์คํ (DVCS)์ด๋ค.
์์ค์ฝ๋ ํ์ ๊ด๋ฆฌ ๋๊ตฌ๋ก์จ, ์์ฑ๋๋์ฝ๋์ ์ด๋ ฅ์ ๊ด๋ฆฌํ๋ค.
์๋์ ์ค์ ์ ์ด๋ ฅ ์์ฑ์(author)๋ฅผ ์ค์ ํ๋ ๊ฒ์ผ๋ก, ์ปดํจํฐ์์ ์ต์ด์ ํ๋ฒ๋ง ์ค์ ํ๋ฉด ๋๋ค.
$ git config --global user.name snowcuphea <<๋ณธ์ธ github ๊ณ์
$ git config --global user.email snowcuphea@gmail.com << ๋ณธ์ธ github ๊ฐ์
์ด๋ฉ์ผ๋ก ๋ณ๊ฒฝ$ git init
Initialized empty Git repository in C:/Useop/TIL/.git/
(master) $- (master)๋ ํ์ฌ ์๋ ๋ธ๋์น ์์น๋ฅผ ๋ปํ๋ฉฐ,
.gitํด๋๊ฐ ์์ฑ๋๋ค. - ํด๋น ํด๋๋ฅผ ์ญ์ ํ๊ฒ ๋๋ฉด ๋ชจ๋
git๊ณผ ๊ด๋ จ๋ ์ด๋ ฅ์ด ์ญ์ ๋๋ค.
์ด๋ ฅ์ ํ์ ํ๊ธฐ์ํด์๋ add ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ staging area ์ stage ์ํจ๋ค.
$ git add . # ํ์ฌ ๋๋ ํ ๋ฆฌ๋ฅผ stage
$ git add README.md # ํน์ ํ์ผ์ stage
$ git add images/ # ํน์ ํด๋๋ฅผ stagestage ๋ฌด๋
์ปค๋ฐ์ ํ๋ ๊ฑฐ๋ฅผ ์ค๋์ต์ ์ฐ๋๋ค ๋ผ๊ณ ํ๋ค.
add๋ฅผ ํ ์ดํ์๋ ํญ์ status๋ช
๋ น์ด๋ฅผ ํตํด ์ํ๋ ๋๋ก ๋์๋์ง ํ์ธํ๋ค.
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: git.md
new file: images/catt.jpg
new file: images/image-20191205161852154.png
new file: markdown.md
git ์ commit ์ ํตํด ์ด๋ ฅ์ ๋จ๊ธด๋ค.
์ปค๋ฐ ์์๋ ํญ์ ๋ฉ์์ง๋ฅผ ํตํด ํด๋น ์ด๋ ฅ์ ์ ๋ณด๋ฅผ ๋ํ๋ด์ผ ํ๋ค.
$ git commit -m 'Init'
[master (root-commit) bda6d07] Init
4 files changed, 144 insertions(+)
create mode 100644 git.md
create mode 100644 images/catt.jpg
create mode 100644 images/image-20191205161852154.png
create mode 100644 markdown.md
์ปค๋ฐ ๋ชฉ๋ก์ ์๋์ ๋ช ๋ น์ด๋ฅผ ํตํด ํ์ธ ๊ฐ๋ฅํ๋ค.
$ git log
commit bda6d0785f0db062181ddbb14eb9db834216e922 (HEAD -> master)
Author: snowcuphea <snowcuphea@gmail.com>
Date: Thu Dec 5 16:52:23 2019 +0900
Init
์๊ฒฉ ์ ์ฅ์๋ ๋ค์ํ ์๋น์ค๋ฅผ ํตํด ์ ๊ณต๋ฐ์ ์ ์๋ค.
github, gitlab, bitbucket
$ git remote add origin https~~~~(URL)์๊ฒฉ ์ ์ฅ์(remote)๋ฅผ origin ์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ํด๋น url๋ก ์ค์ ํ๋ค. // ์๊ฒฉ์ ์ฅ์๋ ํ๋๊ฐ ์๋ ์ฌ๋ฌ๊ฐ ํ ์ ์๋ค. ๋ณดํต origin ์ผ๋ก ๋ง์ด ์ค์ ํ๋ค.
๋ฑ๋ก๋ ์๊ฒฉ ์ ์ฅ์๋ ์๋์ ๋ช ๋ น์ด๋ก ํ์ธํ ์ ์๋ค.
๋ฑ๋ก์ ํ๋ฒ๋ง ์คํํ๋ฉด ๋๋ค.
$ git remote -v$ git push origin masterorigin ์๊ฒฉ ์ ์ฅ์์ push ํ๊ฒ ๋๋ฉฐ, github์์ ํ์ธํ ์ ์๋ค.
์ดํ ์์ ๊ณผ์ ์์๋ add -> commit์ผ๋ก ์ด๋ ฅ์ ๋จ๊ธฐ๊ณ push๋ก ์ ๋ก๋ ํ๋ฉด ๋๋ค.
์ง ํด๋๋ฅผ ๋ง๋ค๊ณ , ๊ฑฐ๊ธฐ๋ค๊ฐ git bash
๊ทธ๋ด์ ๋ ํฌ์งํ ๋ฆฌ ๋ค์ด๊ฐ์ clone or downloads๋๋ฅด๋ฉด https ์ฃผ์ ๋ณต์ฌํด์
๋ณต์ฌํ๋ด์ ๋ช ๋ น์ฐฝ์
git clone ์ฃผ์๋ถ์ฌ๋ฃ๊ธฐ
ํ๋ฉด ์ง ํด๋ ์์ ํด๋น ํด๋๊ฐ ์๊ธด๋ค.