이전에 github에 대용량 파일 올리는 게시글을 올린적이 있다. 댓글은 없지만 조회수가 1,500명이 넘어가는걸 보고 놀랬고, 신기했다. 이번에는 내가 git 사용하면서 많이 사용했던 명령어들을 정리해보고자 한다.
(각 상황별로 정리하였고, 다른 상황에서 겹치는 명령어가 있을 수 있습니다.)
# git 설치 및 버전 확인
git --version
# local git 생성(local git을 생성하고 싶은 위치에서 명령어 실행)
git init
# git repository와 local 연결 및 upload
# git remote add <주소이름> <실제주소>
git remote add origin https://github.com/~
# master branch 생성
# git branch -M <branch 이름>
git branch -M main
# commit - 변경사항 저장
# git commit -m "커밋 내용"
git commit -m "first commit"
# push - 변경사항 git에 upload
# git push -u <저장소(git) 이름> <push 할 branch 이름>
git push -u origin main
# git 설치 및 버전 확인
git --version
# local git 생성(local git을 생성하고 싶은 위치에서 명령어 실행)
git init
# git repository와 local 연결
# git clone <주소>
git clone https://github.com/~
# master branch 생성
# git branch -M <branch 이름>
git branch -M main
# 파일 추가
# git add <파일명>
git add README.md
# commit
# git commit -m "커밋 내용"
git commit -m "file upload"
# push
# git push -u <저장소(git) 이름> <push 할 브랜치 이름>
git push -u origin main
# pull
# git pull <저장소(git) 이름> <push 할 브랜치 이름>
git pull origin main
# merge - branch 작업 병합(메인이 될 브랜치에서 병합할 다른 브랜치 이름을 넣어 실행)
git merge <branch-name>
# 파일 및 폴더 변경 사항 취소 - commit 하지 않은 것들
# 모두 취소
git reset --hard
# 특정 파일만 취소
git checkout -- <filename>
# 파일 및 폴더 추가 취소 - commit만 하고, push는 하지 않은 것(즉, commit한 내용) 취소
git reset
# 새 브랜치 생성
git branch <새로운 브랜치 이름>
# 브랜치 변경
git checkout <전환할 브랜치 이름>
# 브랜치 생성 및 변경 동시 실행
git checkout -b <생성하고 전환할 브랜치 이름>
# 브랜치 삭제
git branch -d <branch-name>
# 브랜치 리스트 보기
git branch
# git log 보기
git log
# 연결된 git 주소 확인
git remote -v