1 ๋ถ„ ์†Œ์š”



์›๊ฒฉ ์ €์žฅ์†Œ(Remote repository)

๊ธฐ๋ณธ ์„ค์ •

  1. ๋‚ด ๋กœ์ปฌ ์ปดํ“จํ„ฐ์˜ ํด๋”๋ฅผ git์ด ๊ด€๋ฆฌํ•˜๋„๋ก ์„ค์ •ํ•œ๋‹ค.
# git์œผ๋กœ ์ดˆ๊ธฐํ™”
$ git init
Initialized empty Git repository in F:/TIL/.git/


# add & commit 
$ git status

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        a.txt
        b.txt

nothing added to commit but untracked files present (use "git add" to track)

$ git add .
$ git status

On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   a.txt
        new file:   b.txt


$ git commit -m "Initial commit"

[master (root-commit) d2c6be1] Initial commit
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt
 create mode 100644 b.txt

  1. Github Repository ์ƒ์„ฑ

image

  • public์€ ๋‹ค ๋ณผ ์ˆ˜ ์žˆ๋Š” ์ €์žฅ์†Œ์ด๋‹ค.
  • private์€ ๋‚˜ ๋˜๋Š” ์ด ๊ถŒํ•œ์ด ์žˆ๋Š” ์œ ์ €๋งŒ ๋ณผ ์ˆ˜ ์žˆ๋Š” ์ €์žฅ์†Œ์ด๋‹ค.



์›๊ฒฉ ์ €์žฅ์†Œ ๋“ฑ๋ก & ์—…๋กœ๋“œ ๋ช…๋ น์–ด

์›๊ฒฉ ์ €์žฅ์†Œ ์ถ”๊ฐ€

  • ์ตœ์ดˆ 1ํšŒ๋งŒ ์„ค์ •ํ•˜๋ฉด ๋จ
# ์›๊ฒฉ ์ €์žฅ์†Œ ์ถ”๊ฐ€
# git์•„ ์›๊ฒฉ ์ €์žฅ์†Œ ์ข€ ๋“ฑ๋กํ•ด์ค˜(add) origin์ด๋ผ๋Š” ์ด๋ฆ„(๋ณ„๋ช…)์œผ๋กœ ์›๊ฒฉ ์ €์žฅ์†ŒURL์„
$ git remote add origin ์›๊ฒฉ์ €์žฅ์†ŒURL
  • ์›๊ฒฉ์ €์žฅ์†Œ url์€ ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•œ๋‹ค.

image

# ์˜ˆ์‹œ
$ git remote add origin https://github.com/IT3AI1/TIL.git



๋“ฑ๋ก๋œ ์›๊ฒฉ ์ €์žฅ์†Œ ํ™•์ธ

$ git remote -v
origin  https://github.com/IT3AI1/TIL.git (fetch)
origin  https://github.com/IT3AI1/TIL.git (push)



์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ์ž˜๋ชป ๋“ฑ๋ก๋˜์–ด ์‚ญ์ œํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ

$ git remote rm origin
$ git remote -v



์›๊ฒฉ ์ €์žฅ์†Œ์— ๋‚˜์˜ ์†Œ์Šค ์ฝ”๋“œ ์—…๋กœ๋“œ

  • add, commit ์ดํ›„์— ์›๊ฒฉ ์ €์žฅ์†Œ์— ๋‚˜์˜ ๋กœ์ปฌ ๋ฒ„์ „ ๊ธฐ๋ก์„ ์—…๋กœ๋“œ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด push ์ง„ํ–‰

  • 2.23 ๋ฒ„์ „์˜ ๋กœ๊ทธ์ธ ์ด์Šˆ

    • ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๋‹ค์‹œ push ์ž‘์—… ์ง„ํ–‰
    $ git config --global credential.git.github.com.provider generic
    
    • ํ˜น์€ vscode์— git bash๋ฅผ ์—ฐ๊ฒฐํ•ด์„œ pushํ•˜๋ฉด ๋ฌธ์ œ ํ•ด๊ฒฐ ๊ฐ€๋Šฅ
$ git push -u origin master # ์ฒซ git push๋ฅผ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ธ์ฆ์„ ์š”๊ตฌํ•˜๋Š” ํ™”๋ฉด์ด ๋‚˜์˜ด
Select an authentication method for 'https://github.com/':
  1. Web browser (default)  
  2. Personal access token  
option (enter for default):  # ๋ฐ”๋กœ enter๋ฅผ ๋ˆŒ๋Ÿฌ์„œ ์ง„ํ–‰

# ์กฐ๊ธˆ ๊ธฐ๋‹ค๋ฆฐ ๋’ค์— github ์‚ฌ์ดํŠธ๋กœ ๋“ค์–ด๊ฐ€์„œ ์ƒˆ๋กœ๊ณ ์นจํ•˜๋ฉด ๋กœ์ปฌ ์ €์žฅ์†Œ์— ์žˆ๋Š” ๋ชจ๋“  ๋‚ด์—ญ์ด ์—…๋กœ๋“œ ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ

# ์ดํ›„์—๋Š” add & commit์„ ์ง„ํ–‰ํ•˜๊ณ  push๋ฅผ ํ•˜๋ฉด ์ƒˆ๋กœ์šด ๋ฒ„์ „์„ ์›๊ฒฉ ์ €์žฅ์†Œ(github)์— ์—…๋กœ๋“œ ํ•  ์ˆ˜ ์žˆ๋‹ค.
$ git push -u origin master

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 214 bytes | 214.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/IT3AI1/TIL.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

image



๊ธฐ๋ณธ ๋ฃจํ‹ด

$ git add .
$ git commit -m "์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€"
$ git push origin master # git์•„ ๋ฒ„์ „ ์ด๋ ฅ์„ push ํ•ด์ค˜ ์–ด๋””๋กœ?! origin(์šฐ๋ฆฌ๊ฐ€ ๋ถ™์ธ ๋ณ„๋ช…)์œผ๋กœ master ๋ธŒ๋žœ์น˜๋ฅผ!

image-20210705165108737



References

ํƒœ๊ทธ:

์นดํ…Œ๊ณ ๋ฆฌ:

์—…๋ฐ์ดํŠธ:

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ