FRONTEND/Git

Git 기초 명령어

MarkLEE 2021. 4. 17. 13:35

오늘은 git을 어떻게 설치 하는지. 

git을 통해 사람들과 어떻게 협업할 수 있는지에 대해 배웠다. 

 

github의 기능과 CLI형식으로 입력할 수 있는 기본적인 git 명령어

  • Fork :  other's remote repositories에서 나의 remote repository로 가져 올때 쓰는 github의 기능
  • clone : <git clone (github repositories의 주소)> 라는 명령어로 사용이 가능하며, 나의 remote repositories에서 local repository로 가져오는 기능을 한다. 
  • status : <git status> 로 사용 가능 local repository로 복사한 directory들의 commited 되기 전 상태를 볼 수 있는 기능    (명령어 사용시 꼭 해당 directory로 들어가서 명령어를 입력하자.)
  • restore: <git restore 파일명> commit 되지 않은 local repository의 변경사항을 폐기(discard) 하고 싶을때. 
  • add : <git add 파일명> commit을 하기 위해서는 먼저 git의 관리하에 있는 폴더로 파일들을 옮겨줘야 한다. 
  • commit: <git commit -m'커밋메세지> add를 통해 staging area에 있는 파일들의 변경사항을 저장(commit)하기 위한 명령어.
  • reset: <git reset HEAD^> local에서 commit한 내용을 취소하고 싶을때. 즉, 아직 remote repository에 commit하지 않고, local repository에만 commit한 경우, reset을 통해 해당 commit을 취소 할 수 있다. 
  • log : <git log>지금까지 git에 commit한 기록(log)를 확인할 수 있다. 
  • pull: <git pull origin master>remote repository에 있는 파일들을 local repo 로 당겨 올수 있는 명령어
  • push : <git push origin master>현재 local에 저장되어 있는 commit기록들을 내 remote repository에 업로드 .
  • init: <git init> git 관할이 아닌 local 파일을 git관할로 만드는 명령어
  • remote add: <git remote add pair url> pair의 remote repo와 나의 컴퓨터를 연결할 수 있는 명령어
  • remote -v: <git remote -v> 현재 연결되어 있는 remote repo의 상황을 보여주는 명령어. 

현재 Local Repository에 저장되어 있는 commit 기록들을 내 Remote Repository 에 업로드

 

 

 

Git의 세 가지 영역 및 상태(Committed, modified, staged)

 

  • committed: local repo 중에 git의 관할에 있는 stage상태에 변경사항을 저장 하는 것. 
  • modified: 기존에 commit한 파일들을 수정한 상태. (unstaged상태. staging area로 올리기 위해서는 새롭게 add하는 것이 필요하다)
  • staged: commit이 가능한 상태. (add명령어를 통해, 수정한 파일을 staging area로 올릴 수 있다.)
  • unmodified: 기존에 commit한 파일을 수정하지 않은 상태.