git tutorials
DESCRIPTION
Git tutorials 를 요약하여 슬라이드로 작성하였습니다.TRANSCRIPT
Git Tutorials
git initgit init
저장소 초기화
git init <directory>
디렉토리 생성과 동시에 저장소 초기화
git init --bare my-project.git
서버에 git 설치 시 쓰임
git clonegit clone <repo-url>
저장소 복사하기
git clone <repo-url> <directory>
폴더 생성 후 저장소 복사하기
git configgit config user.name | user.email <name|email>
<repo>/.git/config 에 저장
git config --global user.name | user.email <name|email>
~/.gitconfig 에 저장.
[alias]st = statusco = checkoutbr = branchup = rebaseci = commit[core]editor = vim
그 밖에,!alias.st <git command>core.editor <editor>
git add
git add <file>
파일 단위 추가
git add <directory>
폴더 단위 추가
working directory -> staging snapshot
git commitgit commit
git config에 지정된 editor 실행 후 커밋로그 작성.
git commit -m <message>
변경된 파일들(!Unstaged)을 확정하고 커밋로그 작성.
git statusgit status
Working Directory, Staged, Unstaged 상태의 파일들을 구분해서 표시.
git loggit log
변경사항이 확정된 내용들을 확인.
--oneline, --stat, -p, --graph 등등
환경변수들을 이용해 다양한 방법으로 커밋로그를 확인.
git checkoutgit checkout master
master 브랜치로 이동
git checkout <commit ex:a1e8fb5>
16진수 7자리로 구성된 HEAD로 이동
git revertgit revert <commit | HEAD>
기존 변경사항 확정내용을 취소하고, 다시 새롭게 변경사항 확정.
git resetgit reset <HEAD^,HEAD~2 등등>
기존 변경사항 확정내용을 취소하고, 다시 새롭게 변경사항 확정.
git resetgit reset <HEAD^,HEAD~2 등등>
HEAD^ : 최근 변경내역 취소HEAD~2 : 최근 변경내역 2개 취소
git cleangit clean
Untracking 상태의 파일을 삭제하는 것을 담당.
git clean -n
삭제하면 어떤 파일에 영향을 받는지 확인.
git clean -f
Untracking 상태의 파일을 삭제.
git branch
git branch <branch-name>
브랜치 생성
git branch -d <branch>
브랜치 삭제
git checkout -b <new-branch-name)
브랜치 삭제
git branch
현재 브랜치 확인
git mergegit merge <branch-name>
브랜치 병합
Rewriting Git Historygit commit --amend
최신 커밋로그 메세지 수정
git rebase -i
불특정 다수의 변경내역을 한개로 병합.
git reflog
지금까지 작업했던 목록들을 확인.리셋하기전에 많이 사용.
git remote - 1git remote
현재 리모트 저장소 상태 확인. "origin"
git remote -v
리모트 저장소 목록 확인.목록을 통해서 다른 사람이 기여한 내용을 쉽게 확인 가능.
git remote add <name> <url>
리모트 저장소 추가.<url>을 저장소를 <name>으로 지정하면, 리모트 저장소에 목록에 저장.
git remote - 2
git remote rename <old-name> <new-name>
리모트 저장소의 이름 수정.
git remote rm <name>
저장소 삭제.
git fetch
git fetch <remote-name>
리모트 저장소에 있는 데이터들을 로컬로 가져옴.언제든지 머지 가능.
git fetch <remote-name> <branch>
데이터들을 로컬 브랜치로 가져옴.
git pull
git pull <remote-name> <branch>
fetch 와는 달리 remote 저장소의 데이터를 가져와서 브랜치 머지.
git push
git push <remote> <branch>
저장소와 브랜치에 데이터 내용을 푸시합니다.
git push <remote> --force|-f
강제로 푸시합니다.
감사합니다. :)