
2021년 6월 24일에 작성된 문서 2번 입니다.
Git 배운 내용을 정리했습니다.
git clone <레파지토리 주소>git statusadd : 파일을 commit 할 수 있는 상태로 , staging area에 unstaged 상태인 파일을 추가git add 파일 이름restore : commit되지 않은 Local Repository의 변경사항을 폐기(discard changes) git restore 파일 이름git commit -m '쓰고 싶은 메시지'git push origin branch 명령어를 사용. git push 뒤에 따라오는 명령어는 상황에 따라 변경 가능.commit한 기록을 취소하고 에러를 수정하고 싶은 경우
reset 명령어를 통해서 commit 을 취소 가능
(단, Remote Repository에 업로드 되지 않고 Local Repository에만 commit 해 놓은 기록)
git reset HEAD
git reset HEAD^ 로 가장 최신의 commit 을 취소할 수 있다. HEAD는 연속된 ^ 의 shortcut. HEAD3 = HEAD^^^ | 이름 | 명령어 | 기능 |
|---|---|---|
| fork | fork 버튼 | 다른 Repository에서 내 Repository에 |
| clone | git clone <레파지토리 주소> | 내 컴퓨터에서 작업하려고 |
| git status | git status | 파일들이 어떤 스테이지에 있는지 |
| add | git add 파일 이름 | 파일 commit 할 수 있는 상태 , staging area에 unstaged 상태인 파일을 추가 |
| restore | git restore 파일 이름 | commit되지 않은 Local Repository의 변경사항 폐기 |
| commit message | git commit -m '쓰고 싶은 메시지 | commit 기록을 남기기 |
| git push | git push origin branch | 현재 Local Repository에 저장되어 있는 commit 기록들을 내 Remote Repository 에 업로드 |
| commit check | git log | 내가 남긴 commit들을 확인 |
| reset | git reset HEAD | commit한 기록을 취소하고 에러를 수정 |
| 최신 commit reset | git reset HEAD^ | 가장 최신의 commit 을 취소 |
git의 Local Repository 영역들
Tracked area 내부 세 가지 상태
Unmodified, Modified, Staged
수정 파일을 commit 하기 위해서 staged area에 add 작업 필요.
init 명령어를 통해 Git의 관리 하에 들어가게 만든다. git init git remote add 명령어를 사용.remote add를 활용git remote -v 명령어로 통해 현재의 Local Repository와 연결된 모든 Remote Repository 목록을 확인pair 변경 사항, 내 변경 사항을 Remote Repository를 통해서 공유
git pull pair master 명령어로 페어의 Remote Repository에 있는 작업 내용을 받아올 수 있다. 받아오는 내용은 자동으로 병합(merge) 됨.
git status 명령어를 통해 어떤 파일이 충돌하고 있는지 확인.Accept Current Change를 클릭해 내가 수정한 내용으로 파일에 반영. Accept Incoming Change를 클릭해서 Remote Repository의 내용으로 파일에 반영. Accept Both Changes는 변경 사항 모두를 반영.Written with StackEdit.