맥에서 깃허브 연동하기

서준이·2023년 3월 11일
0

맥 기본 쉘(zsh) bash로 변경하기

시스템 환경설정 - 사용자 및 그룹 - 현재 사용자에 커서 우클릭 - 고급 옵션 - 로그인 쉘 '/bin/bash'로 변경 - 확인

Homebrew 설치

맥에 git을 설치하기 위해서 패키지 관리자인 Homebrew를 설치해줘야 함

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

(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/example/.profile

eval "$(/opt/homebrew/bin/brew shellenv)"

정상적으로 설치가 완료됐다면 쉘에서 확인해보기

brew --version

git 설치

brew install git

git & github 연동

github에서 repository 생성
로컬 디렉토리 생성 후 디렉토리 이동

mkdir /Desktop/example
cd /Desktop/example

github 계정 설정

git config --config user.name "example"
git config --config user.email "example@example.com"

SSH key 발급

git 연동이 처음이라면 git push 사용 시 권한 오류가 뜸
해결 방법은 SSH key를 발급해서 github에 등록해주면 됨
ssh-keygen -t rsa -C "example@example.com"

SSH key 등록 방법

  • /Users/Users/.ssh/id_rsa.pub 내용 복사
  • Github 접속
  • Setting -> SSH and GPG keys -> New SSH key
  • id_rsa.pub 내용 붙여넣고 저장

SSH key generate가 잘 됐는지 확인하는 법
ssh -T git@github.com

새로 만든 레포지토리 연동 방법

echo "# example" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:exampleid/examplerepository.git
git push -u origin main

기존에 존재했던 레포지토리 연동 방법

git clone git@github.com:exampleid/examplerepository.git

로컬 폴더에 연동 돼 있는 레포지토리 확인 방법

git remove -v

간단한 git 개념

git push - local에서 변경된 내용을 Remote repository에 적용
git pull - Remote repository 내용을 local에 적용 (버전을 맞추는 개념)
git commit - push하기 전 local에서 Remote로 push할 내용을 저장

profile
GNU CS 21

0개의 댓글