git init
git remote add "REMOTE NAME" "REMOTE URL"
git add
git remote update
git push "REMOTE NAME" "BRANCH NAME"
git clone "URL" "FOLDER NAME"
git branch -u origin master
git push -u origin master
(git push --set-upstream origin master)
git remote show "REMOTE NAME"
git branch -vv
git branch -v
git remote rename "BRANCH SRC" "BRANCH DEST"
git pull --allow-unrelated-histories (unrelated histories error)
git push --allow-unrelated-histories
git branch -r 원격 브랜치 표시
git branch -a 모든 브랜치 표시
git branch -d 브랜치 삭제
git ls-files
git log --all --graph --oneline
git log -p: 커밋 간 차이점 출력
git rm "FILE NAME"
git commit -m "COMMIT MSG"
git status
git commit -am "COMMIT MSG"
git reset (staging 해제)
git reset --hard COMMIT_ID
git checkout COMMIT_ID
git rebase COMMIT_ID
git revert COMMIT_ID
git checkout -b BRANCH_NAME: checkout과 branch 생성 한번에
git checkout -t BRANCH_NAME: 원격 저장소 branch로 checkout (git switch -t BRANCH_NAME)
git reset --hard HEAD^ #바로 이전 커밋으로 돌아감(파일이 삭제되거나 이전 버전으로 수정되어버리니 주의)
git reset --hard HEAD~n #위에서부터 n만큼 아래의 커밋으로 돌아감
git reset HEAD^ #가장 최근 커밋을 취소함 (파일은 유지되고 상태만 unstage 또는 untracked 상태로 바뀜)
git reset --soft HEAD^ : 최근 커밋을 취소하고 파일을 staged 상태로 되돌림
git commit --amend --no-edit --date "Mon 12 Jul 2022 12:20:31 KST"
git push -f origin main # 커밋 삭제 후 강제로 푸쉬
git stash
git apply
git stash list
git stash push
git stash pop
git merge origin/master
git mergetool
git config --global user.name "myName"
git config --global user.emain "myName@naver.com"
git config --global credential.helper store (다음 1회만 입력하면 증명 정보 저장)
git config --list
git rm --cached . -rf (깃허브 폴더가 화살표로 나오거나
fatal: in unpopulated submodule 'code/legacy_models/pstage_01_image_classification'
에러가 날 때 해결법, 자주 사용하지 말 것)
git fetch --all --prune
깃허브 GUI에서 브랜치를 삭제한 경우, 터미널에서 여전히 브랜치가 보일 수 있음. 이 때 이미 삭제된 브랜치를 터미널에서도 안보이게 하는 명령어
git push origin -d BRANCH_NAME
원격 브랜치 삭제
최신 git에서는 checkout을 사용하지 않고, switch와 resotre를 사용하는 것을 권장한다.
git switch BRANCH_NAME:
git switch -t BRANCH_NAME: 원격 브랜치 trace
git switch -c BRANCH_NAME: 브랜치 생성과 동시에 checkout
git restore FILE_NAME : last commit 으로 교체
git restore --staged FILE_NAME : stage 해제
export LANG=en_US.UTF-8
git 오류메세지가 한글로 나온다면 bash또는 zsh 세팅에 위 환경변수를 추가해주면 된다.