git 명령어 간단정리

RXDRYD·2021년 8월 15일
0

4년만에 쓰는 git... 가물가물. 복습할겸 정리해놓기

user name(이름), email(이메일) 설정

  • user name(이름) 설정
    git config --global user.name "이름"
  • user email(이메일) 설정
    git config --global user.email "이메일주소"
  • 설정 내용 확인
    git config user.name
    git config user.email

mac 과 windows 환경에 따른 줄바꿈 처리

mac 은 \n , windows 는 \r\n (carriage return 포함)으로 서로 다른 환경에 따른 줄바꿈 처리를 맞춰주기
git config --global core.autocrlf input >> mac
git config --global core.autocrlf true >> windows

git alias

git status 다 입력하기 귀찮을때 ㅋㅋㅋ git st 만 입력!
git config --global alias.st status

git 상태보기

git status
git status -s 축약해서 보기

git 스테이지 영역으로 추가

git add [생성 or 수정한 파일명]
git add . >> 모든 파일 포함해서 스테이징으로

commit 하지 않고 삭제

git rm --cached [파일명]
git rm --cached * >> 다 삭제할경우
삭제하고 나서 git status 해보면 untracked 로 빠져있음

commit 제외 파일 관리

echo [파일명] > .gitignore
.gitignore 파일에 있는 파일명은 commit 할때 제외 됨.

[.gitignore 파일] 
a.out  // a.out 파일 제외
*.log  // log 확장자를 가진 모든 파일 제외 
Temp/  // Temp 폴더 하위 제외 
Temp/*log  // Temp 폴더 하위 log 확장자 파일 제외 

변경사항 확인하기

  • working 영역 내 변경사항 확인
    git diff
  • staged 영역 내 변경사항 확인
    git diff --staged

commit 하기

git commit -m "설명"
git commit -am "설명" >> add 패스하고 바로 all commit

git log 확인

git log

출처

https://www.youtube.com/watch?v=Z9dvM7qgN9s

profile
정리데쓰

0개의 댓글