-
Install and Set Up Git and GitHub on macOSComputer 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
์๋ ์ ํ๋ธ ์์์ ์ฐธ๊ณ ํด์ ์งํ๋์๋ค. ๋๋ฌด ๊น๋ํ๊ฒ ๊น์ ๋ํด ๋ฐฐ์ธ์ ์์๋ ์์์ด๋ค. ๐
'Computer Science > ๊ฐ๋ฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํฐ๋ฏธ๋์์ ๊น ์ปค๋ฐํ๊ธฐ (0) 2023.10.06 Step by step object detection, STEP 1. ๋ฐ์ดํฐ์ ์ค๋นํ๊ธฐ (1) 2023.10.01 [Google Colab] ๋๋ง์ ๋ชจ๋ ๋ง๋ค์ด์ import ํ๊ธฐ (0) 2023.07.30 Day 1) ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ฑ (0) 2023.07.05