TIL 11 | Git, GitHub

saneeeeeeee_Ya·2021년 4월 6일
0

🛸

목록 보기
11/25
post-thumbnail

https://git-scm.com/book/ko/v2

Git : 컴퓨터 파일의 변경사항을 추적하고 여러 명의 사용자들 간에 해당 파일들의 작업을 조율하기 위한 분산 버전 관리 시스템이다

Git 명령어

git status 파일의 상태 확인하기

git log git 히스토리 조회하기
option

  1. --hard [commit log번호] : 돌아가려는 이력이후의 모든 내용을 지워 버린다.
  2. --soft [commit log번호] : 돌아가려 했던 이력으로 되돌아 갔지만 다시 커밋할 수 있는 상태로 남아있다(stage에 남아있다)
  3. --mixed(기본) : 이후에 변경된 내용에 대해서는 남아있지만, 인덱스는 초기화된다
    git revert [commit log번호] : commit을 유지하면서 내용을 복구한다

git branch 로컬 branch 보기
git branch -a로컬/원격 branch 보기
git branch [branch] branch 만들기
git checkout [branch] branch로 들어가기
git checkout -b [branch] branch 병합
git checkout -d [new branch] [원격명/해당 branch] 새 branch에 해당 branch 적용
git merge [branch]
git log --graph --all --decorate 시각화된 작업내역
git rebase branch 재배치
git branch -D [branch] branch 지우기
git config -- global user.name '사용자 이름' 사용자 이름 등록
git config -- global user.email '사용자 email' 사용자 email 등록
git config --global -e 에디터 등록
git config --global alias.[변경 명령어] [기존 명령어] 명령어 변경
git config --h 정보 확인
git clone [url] 저장소 clone
git fetch 깃 변경사항
git pull [원격명] [branch]
git push [원격명] [branch]
git push -d [원격명] [branch] 원격의 branch 삭제
git diff 파일 비교하기,수정내용
git diff --staged Staging Area에 넣은 파일 비교

Work Flow


Working Directory : 쉽게 시각화된 Tree
Index : 바로 다음에 커밋할 것
HEAD : 현재 브랜치를 가리키는 포인터

git init

git add

1. v1

2. v2

git commit

1. v1

2. v2

git reset

git history

1. HEAD 이동
git reset 9e5e6a4

2. Index 업데이트

3. working directory 업데이트

경로를 주고 Reset 하기

file.text를 Stage에서 제거한다
git add file.txt과 반대되는 명령어

특정 커밋을 명시하면 Git은 “`HEAD에서 파일을 가져오는” 것이 아니라 그 커밋에서 파일을 가져온다.

합치기(Squash)
여러 commit을 하나로 합치기

git history

git reset --soft HEAD~2 명령을 실행하여 HEAD 포인터를 이전 커밋으로 되돌릴 수 있다

git commit

git checkout

git checkout [branch]
경로 없음

  1. reset --hard 명령과는 달리 git checkout 명령은 워킹 디렉토리를 안전하게 다룬다
  2. reset 명령은 HEAD가 가리키는 branch를 움직이지만 checkout 명령은 HEAD 자체를 다른 branch로 옮긴다

경로 있음

git reset --hard [branch] file와 같다

요약

HEADINDEXWorking directoryWD safe?
commit Level
reset --soft [commit]REF
reset [commit]REF
reset --hard [commit]REF
checkout [commit]HEAD
File Level
reset [commit]
checkout [commit]
profile
🐜https://action2thefuture.github.io/🐜

0개의 댓글