๐ŸคผGit

TIL) ํ„ฐ๋ฏธ๋„๋กœ ์ ‘๊ทผํ•˜๋Š” ๊นƒ, ๋ช…๋ น์–ด ์ •๋ฆฌ

hellohailie 2022. 5. 22. 23:51

 

mkdir ~/Desktop/codestates

๐Ÿ‘‰Desktop ํŒŒ์ผ์•ˆ์— codestates ํŒŒ์ผ์„ ๋งŒ๋“œ์„ธ์š”.

 

cd ~/Desktop/codestates 

๐Ÿ‘‰codestates ํŒŒ์ผ ์•ˆ์œผ๋กœ ๋“ค์–ด๊ฐ€์„ธ์š”.

 

mkdir my-app

๐Ÿ‘‰my-app ํŒŒ์ผ์„ ๋งŒ๋“œ์„ธ์š”.

 

cd my-app

๐Ÿ‘‰ my-app ํŒŒ์ผ๋กœ ๋“ค์–ด๊ฐ€์„ธ์š”.

 

touch index.html style.css

๐Ÿ‘‰ index.html, style.css ํŒŒ์ผ์„ ๋งŒ๋“œ์„ธ์š”.

 

ls

๐Ÿ‘‰ํ˜„์žฌ ํด๋”์—์„œ ๋ชจ๋“  ํด๋”์™€ ํŒŒ์ผ์„ ๋ณด์—ฌ์ฃผ์„ธ์š”.

index.html style.css

๐Ÿ‘‰touch ๋ช…๋ น์–ด๋กœ ๋งŒ๋“  index.html, style.css์ด ์žˆ์Šต๋‹ˆ๋‹ค. 

 

 

git init

๐Ÿ‘‰ ์ž‘์—…๊ณต๊ฐ„์— local Git repository๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. 

**git clone ์‹œ git init ์•ˆํ•ด๋„ ๋œ๋‹ค. 

 

hint: Using 'master' as the name for the initial branch. This default branch name

hint: is subject to change. To configure the initial branch name to use in all

hint: of your new repositories, which will suppress this warning, call:

hint: 

hint: git config --global init.defaultBranch <name>

hint: 

hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and

hint: 'development'. The just-created branch can be renamed via this command:

hint: 

hint: git branch -m <name>

 

 

git add index.html

๐Ÿ‘‰index.html๋ผ๋Š” untracked file๋ฅผ staging area๋กœ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

git add style.css

๐Ÿ‘‰style.css๋ผ๋Š” untracked file๋ฅผ staging area๋กœ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

 

git status

No commits yet

Changes to be committed:

  (use "git rm --cached <file>..." to unstage)

new file:   index.html

new file:   style.css

๐Ÿ‘‰staging area, untracked files์„ ํ™•์ธํ•˜์„ธ์š”.

 


index.html, style.cssํŒŒ์ผ์„ vs code์—์„œ ์ˆ˜์ • ํ›„ ๋‹ค์‹œ git status ๋ช…๋ น์„ ๋‚ด๋ฆฌ๋ฉด 

On branch master

No commits yet

Changes to be committed:

  (use "git rm --cached <file>..." to unstage)

new file:   index.html

new file:   style.css

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:   index.html

modified:   style.css

 

 

git add *

๐Ÿ‘‰์ž‘์—… ๊ณต๊ฐ„์˜ ๋ชจ๋“  ํŒŒ์ผ์„ staging area๋กœ ์˜ฎ๊ธฐ์„ธ์š”.

 

์ถ”๊ฐ€ ๊ณต๋ถ€ git add * vs git add .

 

 

 

 

git commit -m "๋‚˜์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ html, css ์™„์„ฑ"

[master (root-commit) d805507] ๋‚˜์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ html, css ์™„์„ฑ

 2 files changed, 15 insertions(+)

 create mode 100644 index.html

 create mode 100644 style.css

๐Ÿ‘‰์ˆ˜์ • ์ž‘์—…์ด ๋๋‚ฌ๊ณ , ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ €์žฅํ•˜์„ธ์š”. ๋ฉ”์„ธ์ง€๋Š” "๋‚˜์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ html, css ์™„์„ฑ"๋ผ๊ณ  ๋‚จ๊ธฐ์„ธ์š”.

 

๐Ÿ”ด์ด๋•Œ ๋ฉ”์„ธ์ง€๋Š” ๊ธฐ๋Šฅ ๊ตฌํ˜„์„ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋„๋ก, ์ •ํ™•ํ•œ ๊ธฐ์ˆ  ์šฉ์–ด ์‚ฌ์šฉํ•˜๊ณ  ์งง๊ณ  ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์จ์•ผํ•ฉ๋‹ˆ๋‹ค.

 

 

 

git status

๐Ÿ‘‰staging area, untracked files์„ ํ™•์ธํ•˜์„ธ์š”.

 

On branch master

nothing to commit, working tree clean

๐Ÿ‘‰ staging area, untracked files์„ ํ™•์ธํ•ด๋ณด๋‹ˆ ์ €์žฅํ•  ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์—†์Šต๋‹ˆ๋‹ค. 

 

 

 

touch code.svg eat.svg repeat.svg sleep.svg

๐Ÿ‘‰code.svg eat.svg repeat.svg sleep.svg ํŒŒ์ผ์„ ๋งŒ๋“œ์„ธ์š”.

 

 

git add code.svg eat.svg repeat.svg sleep.svg

๐Ÿ‘‰code.svg eat.svg repeat.svg sleep.svg ํŒŒ์ผ์„ staging area๋กœ ์˜ฎ๊ธฐ์„ธ์š”.

 

git commit -m "feat: ๊ฐ ๋ฒ„ํŠผ์— ๋งž๋Š” ์‚ฌ์ง„ ์ฒจ๋ถ€"

๐Ÿ‘‰"feat: ๊ฐ ๋ฒ„ํŠผ์— ๋งž๋Š” ์‚ฌ์ง„ ์ฒจ๋ถ€"๋ผ๊ณ  ๋ฉ”์„ธ์ง€๋ฅผ ๋‚จ๊ธฐ๊ณ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ €์žฅํ•˜์„ธ์š”.

[master eec1af7] feat: ๊ฐ ๋ฒ„ํŠผ์— ๋งž๋Š” ์‚ฌ์ง„ ์ฒจ๋ถ€

 4 files changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 code.svg

 create mode 100644 eat.svg

 create mode 100644 repeat.svg

 create mode 100644 sleep.svg

 

 

 

 

touch README.md

๐Ÿ‘‰README.md ํŒŒ์ผ์„ ๋งŒ๋“œ์„ธ์š”.

 

git add README.md

๐Ÿ‘‰ README.md ํŒŒ์ผ์„ staging area๋กœ ์˜ฎ๊ธฐ์„ธ์š”.

 

git commit -m "docs: README.md ์ž‘์„ฑ"

๐Ÿ‘‰"docs: README.md ์ž‘์„ฑ"๋ผ๊ณ  ๋ฉ”์„ธ์ง€๋ฅผ ๋‚จ๊ธฐ๊ณ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ €์žฅํ•˜์„ธ์š”.

[master 2fbd393] docs: README.md ์ž‘์„ฑ

 1 file changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 README.md

 

 

git remote add origin git@github.com:HelloHailie/my-first-github-repository.git

๐Ÿ‘‰ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ๋Š” git@github.com:HelloHailie/my-first-github-repository.git ์ด๊ณ ,

์ด๋ฅผ ์•ž์œผ๋กœ origin์ด๋ผ๋Š” ์ด๋ฆ„์„ ์‚ฌ์šฉํ•˜๋ฉด ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

 

remote ์ถ”๊ฐ€๊ณต๋ถ€ 

git remote add <name> <URL> 

<name>: ์•ž์œผ๋กœ ๋กœ์ปฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ๋ฅผ ๋Œ€์‹ ํ•  ์ด๋ฆ„ (ex: origin)

<URL>: ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ฃผ์†Œ (ex: git@github.com:codestates-seb/agora-states-fe.git )

 

**git remote๊ฐ€ ๋ฐ”๋กœ ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด

***git remote add origin https://github.com/[์ด๋ฆ„]/gitExample๋กœ origin์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์›๊ฒฉ ์ €์žฅ์†Œ ์ฃผ์†Œ๋ฅผ ๋“ฑ๋กํ•œ๋‹ค.

์ด์ œ๋ถ€ํ„ฐ origin์ด๋ผ๋Š” ์ด๋ฆ„์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐฉ๊ธˆ ์ „์— ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  ์ €์žฅ์†Œ์— ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋‹ค. (origin์ด๋ผ๊ณ  ์•ˆ ํ•˜๊ณ  ๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ํ•ด๋„ ๋œ๋‹ค.) ๋งŒ์•ฝ origin์ด๋ผ๋Š” ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ์ง€์šฐ๊ณ  ์‹ถ๋‹ค๋ฉด git remote remove originํ•˜๋ฉด ๋œ๋‹ค.

 

 

git remote -v

๐Ÿ‘‰ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๊ฐ€ ์ž˜ ์—ฐ๊ฒฐ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

 

 

git push -u origin main

๐Ÿ‘‰  ๋กœ์ปฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— ๊ธฐ๋กํ•œ ๋‚ด์—ญ์„ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ์˜ฎ๊ธฐ์„ธ์š”.

 

 

git push ์ถ”๊ฐ€๊ณต๋ถ€ 

git push <remote> <branch>

<remote> ์—๋Š” ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ์ด๋ฆ„์„ ์ž…๋ ฅ

<branch> ์—๋Š” ๋ธŒ๋žœ์น˜ ์ด๋ฆ„์„ ์ž…๋ ฅ 

 

์˜ˆ๋ฅผ๋“ค์–ด git push origin main

๐Ÿ‘‰๋กœ์ปฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ๊ธฐ๋ก์„ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ origin์˜ main ๋ธŒ๋žœ์น˜๋กœ pushํ•˜์„ธ์š”.

 

์ถ”๊ฐ€ํ•™์Šต

Git ๋ธŒ๋žœ์น˜

 

 

cat config

๐Ÿ‘‰ ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ํ„ฐ๋ฏธ๋„์— ์ถœ๋ ฅํ•˜์„ธ์š”.