GIT 명령어

BG·2021년 5월 24일
0

GIT

목록 보기
1/1
post-thumbnail

GIT 명령어 메모장입니다!!


[git 초기설정]
git init
-> git로 관리할 대상 폴더에서 명령어 실행

[git commit]
git add [파일명] or git add . (.은 현재 경로의 의미)
git commit -m [메세지]

[local git과 github repo 연결 AND PUSH]
git remote origin [레포지토리 주소]
-> 이미 연결되어 있으면 안해도 상관없음

git push origin [branch명]

[git 상태값]
git status
-> add가 완료된 파일은 초록색, 수정했지만 add 되지 않은 파일은 빨간색
git log
-> commit한 내역들을 보여준다. 빠져 나올려면 q

[가장 마지막 commit로 되돌리기]
git checkout --파일명

[중간저장]
중간저장 : git stash OR git stash save
중간저장 리스트 보기 : git stash list
stash 불러오기
-> git stash apply(가장 최근 저장값 불러오기)
-> git stash apply [stash이름]
-> git stash apply --index(staged 상태로 불러오기)
stash 삭제
-> git stash drop : 가장 최근 저장값 삭제
-> git stash drop [파일명]
-> git stash clear : stash 전체 삭제

[add 취소]
git reset [파일명]

[commit 취소]
staged된 상태로 돌림 : git reset --soft HEAD^
unstaged된 상태로 돌림 : git reset HEAD^
마지막 2개의 commit을 취소 : git reset HEAD~2

[마지막 commit 상태로 되돌리기]
git checkout [파일명] : 작업했던것 다 날라가니 주의
-> git checkout . : 현재 경로의 모든 파일을 마지막 commit상태로~
-> git checkout test/test.c : test/test.c의 파일만 마지막 commit로 돌리기

[강제 pull]
git fetch --all
git reset --hard origin/master

[강제 push]
git push origin main -f

[rebase]
git rebase -i main

  • 스쿼시 커밋 합치기
  • 커밋 메세지 수정
profile
글쎄...?

0개의 댓글