Git
잘 까먹는 Git 명령어들을 정리해봤다.
Remote Repository 만들기
- home에 repository 폴더 생성
cd /home/chorockuin mkdir remote_repository.git cd remote_repository.git - 생성한 repository를 remote repository로 설정
git init --bare --shared - 원격에서 repository로 접속
git clone ssh://chorockuin@x.x.x.x:/home/chorockuin/remote_repository.git - 원격에서 initial commit
git init . git add git commit - 원격에서 push
git push origin master
Repository History 초기화
- 방법1
git init git add . git commit git remote add origin 'remote_repository_url' git push -f --set-upstream origin master - 방법2
git checkout --orphan 'lastest_branch' git branch -D master git branch -m master git push -f origin master
Tag
- 조회
git tag git tag -l 'tag_name_keyword' - 추가
git tag 'tag_name' git tag -a 'tag_name' -m 'tag_message' - 삭제
git tag -d 'tag_name' - 원격 저장소에 추가
git push origin 'tag_name' git push origin --tags - 원격 저장소에서 삭제
git push origin :'tag_name' - 태그에 해당하는 커밋 및 메시지확인
git show 'tag_name' - 태그로 체크아웃 & 브랜치 생성
git checkout tags/'tag_name' -b 'branch_name'
돌아가기
- 이전 단계(1,2,3,4,…) 커밋으로 돌아가기
git checkout HEAD~'1,2,3,4,...' - 특정 커밋으로 돌아가기
git checkout 'commit_hash_value'
remote branch 가져오기
- remote update
git remote update - remote branch 확인
git branch -r - remote branch 가져오기
git checkout -t 'branch name'git checkout -t origin/feature/xxx
git add 취소
git reset
line ending 설정
git config --global core.autocrlf true
git config --global core.eol native
git config --global core.eol lf
git config --global core.eol crlf
git config --global --list