Git 명령어
Updated:
깃 문서 참고
버전확인
git --version
설정확인
git config --list
config vscode로 열기
git config --global -e
git config --global core.editor "code --wait"
이름/이메일 설정
git config --global user. name ""
git config --global user.email ""
운영체제 문자열 통일
git config --global core.autocrlf true(윈도우)/input(맥)
초기화(로컬저장소 생성)
git init
제거
rm -rf .git
파일생성
echo *.log > .gitignore 내용 > 파일이름
상태확인
git status
git status -h 도움말
git status -s 간단하게 확인
명령어 줄이기
git config --global alias.st status
파일 트래킹(스테이지에 올리기)
git add
git add . 모든파일추가
파일 언트래킹(스테이지에서 내리기)
git rm --cached
파일내용 확인
cat
파일변경내용 확인
git diff
git diff --staged 스테이지에 올라가있는 파일확인
git diff --cached 스테이지에 올라가있는 파일확인
파일변경내용 vscode에서 확인하기
.gitconfig에 다음내용 추가
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
gitdifftool
커밋
git commit
git commit -m "" 커밋메세지작성
git commit -am "" 스테이지와 워킹디렉토리의 모든파일 메세지와 함께추가
히스토리확인
git log
폴더 레포지토리에 연결하기
git remote add origin https://github.com/koppy364/node.git
git remote -v
repository에 파일 업로드
git push -u origin main
-u 옵션은 이 다음부터는 git pull / git push 를 할 때
origin main을 지정하지 않아도 알아서 origin main 붙어서 가져오라는 옵션
레포지토리 합치기
git subtree add --prefix=사용할폴더명 레포지토리주소 브랜치명
ex) git subtree add --prefix=BasicWeb https://github.com/koppy364/web.git main
Leave a comment