ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Install and Set Up Git and GitHub on macOS
    Computer Science/๊ฐœ๋ฐœ 2023. 8. 14. 18:19
    ๋ฐ˜์‘ํ˜•

    ๏นก

     

    1. Git ์„ค์น˜

    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    $ brew install git
    $ sudo port install git

    Git ์„ค์น˜ ์ „์— Homebrew ์„ค์น˜๊ฐ€ ์•ˆ๋˜์–ด์žˆ๋‹ค๋ฉด 

    ์œ„ ์ฝ”๋“œ ๋ธ”๋ฝ์˜ ์ฒซ๋ฒˆ์งธ ๋ช…๋ น์–ด๋กœ ์„ค์น˜ํ•œ๋‹ค. 

     

    2. Git ์…‹์—…ํ•˜๊ธฐ

    $ git config --global user.name "<your name>"
    $ git config --global user.email <your email address>
    $ git config --global core.editor vi

    ์›๊ฒฉ์—์„œ ์ž‘์—…ํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜ ๋ช…๋ น์–ด๋„ ํ•ด์ค€๋‹ค.

    $ git config --global --add push.default current
    $ git config --global --add push.autoSetupRemote true

     

    3. GitHub ๋กœ๊ทธ์ธ์„ ํ•ด์ค€๋‹ค. 

     

    4. Settings - SSH and GPG Keys ๋กœ ๋“ค์–ด๊ฐ„๋‹ค. 

    • SSH keys ์˜ generating SSH keys ํด๋ฆญ
    • Generating a new SSH key and adding it to the ssh-agent ํด๋ฆญ
    $ ssh-keygen -t ed25519 -C "abcd@email.com" # (Github ๊ฐ€์ž…ํ•  ๋•Œ ์‚ฌ์šฉํ–ˆ๋˜ ์ด๋ฉ”์ผ ์ฃผ์†Œ)
    • passphrase๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

    ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ด๋ฏธ์ง€๊ฐ€ ๋œจ๋ฉด ์„ฑ๊ณต์ด๋‹ค.

     

    5. ~/.ssh/config ํŒŒ์ผ์„ ์ˆ˜์ •ํ•œ๋‹ค. 

    $ cd ~/ .ssh
    $ eval "$(ssh-agent -s)"
    $ open ~/.ssh/config
    $ touch ~/.ssh/config
    $ vi -e config
    # vi ํŽธ์ง‘๊ธฐ๋กœ ์•„๋ž˜ ๋‚ด์šฉ์„ config ํŒŒ์ผ์— ๋ถ™์—ฌ๋„ฃ๋Š”๋‹ค.
    Host github.com
      AddKeysToAgent yes$
      UseKeychain yes$
      IdentityFile ~/.ssh/id_ed25519
      
    $ cat config
    $ ssh-add -K ~/.ssh/id_ed25519

     

    ๋งˆ์ง€๋ง‰ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ–ˆ์„ ๋•Œ ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋ฉด ๋œ๋‹ค. 

     

     

    6. GitHub ์—์„œ SSH key๋ฅผ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

    $ pbcopy < ~/.ssh/id_ed25519.pub

     

    ํ•ด๋‹น ๋ช…๋ น์–ด๋Š” id_ed25519.pub ํŒŒ์ผ ์•ˆ์˜ ๋‚ด์šฉ์„ ํด๋ฆฝ๋ณด๋“œ์— ๋ณต์‚ฌํ•œ๋‹ค.

     

    7. Github์˜ ํ”„๋กœํ•„-settings-SSH and GPG keys๋กœ ์ด๋™

    • New SSH key ํด๋ฆญ
    • Title ์— ์›ํ•˜๋Š” key ์ด๋ฆ„์„ ๋„ฃ๊ณ ,
    • Key ๋ถ€๋ถ„์— ์ข€์ „์— ๋ณต์‚ฌํ•œ ๋‚ด์šฉ์„ ๋ถ™์—ฌ๋„ฃ๋Š”๋‹ค. 
    • Add SSH key

    ๊ทธ๋Ÿฌ๋ฉด ์ด๋ ‡๊ฒŒ SSH key๊ฐ€ ์ƒ๊ธด ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

     

     

    8. SSH connection ํ…Œ์ŠคํŠธํ•˜๊ธฐ

    $ ssh -T git@github.com

    ์ด๋Ÿฌ๋ฉด ์…‹์—…์ด ๋๋‚ฌ๋‹ค.

     

    9. GitHub์— ์ƒˆ repository๋ฅผ ๋งŒ๋“ค๊ณ  ๋กœ์ปฌ์—์„œ ๊นƒํ—ˆ๋ธŒ๋กœ ์ฝ”๋“œ๋ฅผ ์˜ฌ๋ ค๋ณด์ž.

    • Repository name ์„ ์„ค์ •ํ•ด์ค€๋‹ค.
    • Add a README file ์ฒดํฌ
    • Add .gitignore ์•„๋ž˜์— template์„ None์—์„œ Python์œผ๋กœ ๋ณ€๊ฒฝ
    • Code ์—์„œ SSH๋ฅผ ์„ ํƒํ•˜๊ณ  SSH key๋ฅผ clone ํ•œ๋‹ค.
    •  

     

    10. ๋‹ค์‹œ ํ„ฐ๋ฏธ๋„๋กœ ์™€์„œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ  SSH key๋ฅผ ๋ถ™์—ฌ๋„ฃ๋Š”๋‹ค.  

    $ cd
    $ mkdir -p vcs/github.com/{name} # (version control system)
    $ git clone {SSH key ๋ณต์‚ฌํ•œ ๊ฒƒ ๋ถ™์—ฌ๋„ฃ๊ธฐ}
    $ ls -la

     

    11. PyCharm CE์—์„œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์— ์ƒˆ ํด๋”๋ฅผ ๋งŒ๋“ค๊ณ  .py ํŒŒ์ผ ํ•˜๋‚˜ ์ƒ์„ฑ

    $ PyCharm CE .

    Pycharm์œผ๋กœ ๋“ค์–ด์™€์„œ ์™ผ์ชฝ Project ์—์„œ ์ƒˆ ํด๋” (intro) ๋ฅผ ๋งŒ๋“ ๋‹ค.

    github์— ์˜ฌ๋ฆด hello.py๋„ ๋งŒ๋“ค์–ด์ค€๋‹ค.

     

    12. git add, git commit, git push

    $ cd /vcs/github.com/jicodes/python-coursework
    $ git add intro/hello.py
    $ git status
    $ git commit -m "Add hello.py" # commit ๋ฉ”์„ธ์ง€
    $ git remote -v
    $ git push

     

     

    ์•„๋ž˜ ์œ ํŠœ๋ธŒ ์˜์ƒ์„ ์ฐธ๊ณ ํ•ด์„œ ์ง„ํ–‰๋˜์—ˆ๋‹ค. ๋„ˆ๋ฌด ๊น”๋”ํ•˜๊ฒŒ ๊นƒ์— ๋Œ€ํ•ด ๋ฐฐ์šธ์ˆ˜ ์žˆ์—ˆ๋˜ ์˜์ƒ์ด๋‹ค. ๐Ÿ‘

    https://youtu.be/tiQXqQ1YSPM

Designed by Tistory.