코딩하는 해맑은 거북이

[Github] Github 명령어 모음 본문

ETC

[Github] Github 명령어 모음

#CJE 2023. 3. 13.

- 저장소 만들기

git init

 
- 저장소 복제

git clone (url)

 
- user.name과 user.emil 등록

git config --global user.name (name)
git config --global user.email (user@gmail.com)

 

- 수정파일 stage 에 올리기

 git add (파일명)


- 커밋 생성 - 코드 변경 이력 남기기

git commit -m (message)

 

- 커밋 생성 : tracked 상태의 파일만 auto add "-a" 옵션

 git commit -am (message)

 

- 마지막 버전의 commit message 변경

git commit --amend -m "new_message"


- 원격 저장소로 전송

git push

 
저장소의 변경 내용을 현재 디렉토리에 가져오기

git pull

→ git fetch + git merge
 
- branch 목록 확인

git branch

 
예전 commit 상태로 돌아가기

git checkout (브랜치명)

 
작업 디렉토리의 변경 사항을 staging area에 추가(일부 수정사항만 commit할때 사용)

git add (파일명)

 
현재 상태 확인

git status

modified : 한번 commit 했던 파일

Untracked : 한번도 commit 하지않았던 파일

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   work1.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        work2.txt

 

전체 로그 확인 (종료할때 q)

git log

 
터미널에서 log를 한줄로 확인

git log --oneline

 
터미널에서 log를 한줄로 graph 형태로 확인

git log --oneline --graph --all

 
버전 간의 차이점 비교

git log -p
git diff "버전id" "버전id2"

 
add 전과 후를 비교

git diff

 
예전 버전으로 돌아가기

git reset --hard "버전id"

 
로컬 저장소에서 사용한 프로젝트를 원격 저장소로 연결

git remote add (url)

 

- 기타 : github commit message template 적용

git config --global commit.template ./gitmessage.txt

'ETC' 카테고리의 다른 글

[기업탐색] 도움되는 사이트  (1) 2023.11.12
[프론트엔드] 쉽고 빠른 웹 개발 - Bootstrap  (0) 2023.07.18
[운영체제] Program, Process, Thread  (0) 2023.06.11
[리눅스] Shell Command  (0) 2023.04.25
Comments