Git 공부하면서 정리한 자료
- Git 명령어 정리
- 소스 코드 관리를 위한 Git 사용법 총 정리
- Git Tutorial for Beginners: Learn Git in 1 Hour
- GitHub GitHub 정리하기
- git 깃허브 정리
- Commit message 작성 규칙
- Github, Git Commit Rule (깃허브 커밋 룰)
- 업데이트 | 가장 위험한 깃 실수 6가지와 빠른 수습 방법
- [Git] git stash 명령어 사용하기
- Git - fast-forward merge 란? fast-forward & 3-way Merge의 차이점
- [GIT] 병합(merge) 종류 별 완벽 설명
- 브랜치 통합하기
- Git 브랜치 - Rebase 하기
- 깃(Git) 커밋 가이드
git config
명령어를 통해 계정정보를 설정합니다.
$ git config --global user.name "name"
$ git config --global user.email "name@domain.com"
$ git config --global core.autocrlf true
$ git config --global core.autocrlf input
Mac : Zsh with Git plugin
Windows: posh-git
Windows: windows terminal(beta)
# code --wait 입력 시 git파일이 닫힐때 까지 git 터미널이 대기상태
$ git config --global core.editor "code --wait"
$ git add file1.txt # 단일 추가
$ git add file1.txt file2.txt # 복수 추가
$ git add *txt # 패턴매치 추가
$ git . # 현 경로에 있는 모든항목 추가 (재귀적 탐색포함)
$ git add . -f # ignore파일 및 삭제파일 이력 커밋한 경우
$ git status # 현재 staging 된 항목과 현재 레포지터리에 있는 파일비교
$ git commit -m "메모"
$ git commit # 메모없이 진행 할 경우 COMMIT_EDITMSG파일에 저장된 default 메시지 값으로 커밋 메시지 반영
# Skipping Staging Area and commit
$ git commit -a -m "메모" # commit all modified files
$ git mv filename.txt newfilename.txt
$ git log
$ git log --oneline # 요약본
$ git log --stat # 파일 변동사항 확인
$ git --stat # 각 커밋의 자세한 내역확인
$ git --oneline --patch # 각 파일의 변경내역 확인
$ git log --oneline -3 # 마지막 3개 커밋내역 확인
$ git log --oneline --author="이름" # 커밋 생성자 이름으로 확인
$ git log --oneline --before="2021-12-31" # 날짜 기준으로 조회
$ git log --oneline --after="2021-12-31" # 날짜 기준으로 조회
$ git log --oneline --after="yesterday" # 어제 이후 커밋조회
$ git log --oneline --after="one week ago"
$ git log --oneline --after="one month ago"
# 커밋 메시지 기준으로 조회
$ git log --oneline --grep="커밋 메시지"
$ git log --oneline --grep="커밋 메시지"
# 변경된 코드기준으로 조회
$ git log --oneline -S"코드"
# 변경된 코드기준으로 커밋된 파일내역 확인
$ git log --oneline -S"코드" --Patch
# 범위기준으로 조회
$ git log --oneline [commit해쉬1]..[commit해쉬2]
# 파일변경기준으로 조회
$ git log --oneline -- "파일이름"
$ git log --oneline --patch -- "파일이름" # 패치내역까지 조회
$ git diff # 현재 수정중인 파일과 commit된 파일비교
$ git diff --staged # add된 파일과 commit된 파일비교
$ git diff [commit해쉬1]..[commit해쉬2] # commit간의 비교
$ git diff HEAD HEAD^ # 가장 최근의 커밋과 그 전의 커밋을 비교
# Current branch, diff between commits 2 and 3 times back
$ git diff HEAD~3 HEAD~2
# Create new branch
$ git branch [브랜치명]
# list branches
$ git branch
# 현재 활성화된 git branch 확인
$ git status
>>> on branch master
# branch 이동 (2가지 방법)
# Switch branches
$ git checkout [브랜치명]
# Switch branches or restore working tree files
$ git switch [브랜치명]
# Restore working tree files
$ git restore [브랜치명]
# Create new branch and move to the branch
$ git switch -C [브랜치명]
$ git checkout -b [브랜치명]
# rename branch
$ git branch -m [old name] [new name]
# delete branch
# merge가 된것들만 한하여 삭제
$ git branch -d [브랜치명]
# delete branch by Force
$ git branch -D [브랜치명]
# comparing branch
# show all the log commits in the branch that are not in master branch
$ git log master..[브랜치명]
# show all difference between two branch
$ git diff master..[브랜치명]
$ git diff [브랜치명] # master.. 생략해도 자동으로 마스터 브랜치랑 비교
# 변경된 파일만 확인 시
$ git diff --name-status [브랜치명]
Stroing in safe place but doens't record in history
$ git stash push -m "메시지"
# stash push all
$ git stash push -am "메시지"
# list satsh
$ git stash list
# show stash change
$ git stash show [인덱스 숫자]
# drop stash
$ git stash drop [인덱스 숫자]
# drop all stash
$ git stash clear
$ git slog --oneline --all --graph
## --ff 는 기본설정이다
$ git merge [브랜치명]
# fast-forward의 관계라도 merge commit 실행
$ git switch master
$ git merge --no--ff [브랜치명]
# 기본값 경로: origin/master
$ git push [브랜치명]
$ git push -f # 강제로 푸쉬하기 # 절대로 쓰지 말자
$ git fetch
$ git pull
$ git merge origin/master