깃(Git)의 특징
버전 관리(Version Control)
백업(Backup)
협업(Collaboration)
/bin/bash -c "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew install git
사용자 정보 입력
$ git config --global user.name "사용자이름"
$ git config --global user.email "사용자이메일"
줄바꿈 문자열
운영체제 별로 줄바꿈 문자열을 처리하는 방식이 달라서 충돌이 날 수 있음
$ git config --global core.autocrlf true
$ git config --global core.autocrlf input
버전이란?
스테이지와 커밋
작업 트리(working tree)
스테이지(stage)
저장소(repository)
버전 생성 과정
$ git add . // 전체 파일
$ git add 파일명 // 특정 파일
$ git commit -m '커밋메시지'
지역 저장소(local repository)
원격 저장소(remote repository)
저장소(repository) 생성
원격 저장소 주소
https://github.com/아이디/저장소이름
폴더 생성→ 깃 초기화
리액트에서는 디폴트로 설정되어 있음
$ git init
$ git add . // 전체 파일 스테이징
$ git add 파일명 // 특정 파일만 스테이징
$ git commit -m '커밋메시지'
$ git branch -M main
$ git remote add origin 원격_저장소_주소
// 저장소 변경 시 -> origin의 저장소 초기화
$ git remote rm origin
$ git push -u origin main
💡 한번 스테이징을 거친 파일은 git add . → 명령어 생략 가능
$ git commit -am “second commit” → 이런 식으로 스테이징과 커밋을 동시에 할 수 있음
[팀장]
[팀원]
$ git clone https://github.com/팀장계정/프로젝트이름.git
$ git branch gyull
$ git switch gyull
$ git add .
$ git commit -m "gyull first commit"
$ git push origin 브랜치이름
// 예) gyull 브랜치에 파일 업로드
$ git push origin gyull
[전체]
$ git add .
$ git commit -m "second commit"
$ git pull origin main