Git 용어 및 Github 공유

River·2023년 4월 4일
0

Git & Github

목록 보기
2/2
post-thumbnail

Git 명령어 및 용어

  • repository or repo: 저장소 (git 으로 버전 관리하는 directory)
  • local repo: 작업자 PC 에 설정된 git 저장소
  • remote repo: Github 등 외부 서버에 설정된 git 저장소
  • commit: 특정 상태 기록 == 버전
  • branch: 다른 작업공간
  • merge: 특정 branch에서 작업한 내용을 또 다른 branch에 적용
  • git init: local git 저장소 설정
  • mkdir: create directory
  • cd: go to specific directory
  • touch: create empty file
  • echo "text" >> file: file 에 text 추가
  • git reset: 특정 commit 까지 이력 초기화
  • git revert: 특정 commit 취소하는 새로운 commit 만들기
  • git switch -c: crete branch and go to that branch
    • 새 branch 만들 때 현재 branch 상태를 기준으로 만들기에 현재 branch 확인 필요
  • git switch == gsw branch_name: change branch
  • git merge: merge branch
  • git push -u origin main == gp -u origin main
  • git pull == gl
git switch main // gsw main, go to the main branch
git merge penguin // gm penguin, penguin branch 의 내용을 main 에 merge 

conflict

  • 충돌 해결하고 commit or merge 작업 취소
  • git merge --abort
    참고 사이트

Github 공유 방법

1. local repo -> remote repo

1) local repo 에서 작업 진행
2) create Github remote repository
3) git remote add origin github_repo_link
4) git branch -M main (메인 branch를 main 으로 설정, 이미 branch 가 main 이라면 생략)
5) git push -u origin main (gp -u origin main)

2. remote repo -> local repo

1) 원하는 local 위치로 이동
2) git clone github_repo_link

3. remote repo -> local repo (변경사항 가져오기)

git pull # gl
profile
Passionate about My Dreams

0개의 댓글