[Git] 기초

seongmin·2022년 9월 4일
0

Git

목록 보기
1/3
post-thumbnail

Git

  • 각 파일의 버전을 관리할 수 있게 함
  • 파일의 백업이 가능
  • 협업자들과 파일 공유 및 취합 가능

명령어

  • Fork : 다른 사람의 Repository 전체를 나의 Repository로 가져오는(복사) 기능

  • clone : Repository의 파일들을 내 컴퓨터로 가져오는 명령어

    git clone repository의 http 주소
  • status : 현재 Local Repository에 변경된 파일이 있는지 확인하는 명령어. staging areauntracked files 목록에 어떤 것들이 있는지 확인 가능하다.

    git status
  • restore : commit 되지 않은 Local Repository의 변경 사항을 폐기할 수 있다.
    -> clone 으로 받아 왔던 상태로 돌아간다.

    git restore 파일명
  • add : staging area 로 파일을 추가한다. // git add 했을 때 터미널 상의 변화는 없다.

    git add 파일명 // git add . (unstaged 된 모든 파일을 한번에 추가)
  • commit : staging area 올라간 파일을 커밋할 수 있다.

    git commit -m '커밋 메시지'
  • reset : Local Repository 에만 commit 한 기록을 취소할 수 있다.

    git reset HEAD^ // 가장 최신의 commit을 취소한다.
  • log : coommit 이 잘 업로드 되었는지 확인한다. // 현재까지 commit된 내역들을 확인함.

    git log 
  • pull : Remote Repository의 해당 branch 내용을 Local Repository로 가져온다.

    git pull <shortname> <branch>
    // ex. git pull pair main -> 페어의 remote repositorydml main 브랜치 내용을 가져옴
  • push : Local Repository에 commit 된 기록들을 Remote Repository로 업로드한다.

    git push origin main <branch> // 리모트된 origin의 main branch로 업로드
  • init : 디렉토리를 Git Repository로 변환하거나 새로운 Repository를 초기화하는데 사용한다.

    git init
  • remote add : Local Repository에 Remote Repository를 연결

    git remote add origin <Repository 주소>

    기존 리포지토리 remote 제거

    git remote remove origin
  • remote -v : 현재 Local Repository와 연결된 모든 Remote Repository 목록을 확인

    git remote -v
  • Pull Request : Remote Repository에 push 해 놓은 변경 사항에 대해 협업자들에게 알리는 것.

  • ssh -T git@github.com : github에 ssh key가 잘 연결되었는지 확인한다.

0개의 댓글