본문 바로가기

Git

Git 초기 셋팅 및 명령어

 1. Git 설치

https://git-scm.com/ 

 

Git

 

git-scm.com

2. Git 사용자 설정 (Git 설치 후 최초 한번만 설정)

 

1-1 명령 프롬프트 실행

 

1-2 git config --global user.name "사용자이름" = 초기 이름 설정

 

1-3 git config --global user.email "이메일 주소" = 초기 이메일 설정

 

 

 

3. local 저장소 생성

cd 작업할 저장공간으로 링크

명령 프롬프트 창에

>git init 입력

= 해당 폴더에 .git 폴더 생성

 

 

 

4. commit 1cycle 

 

1-1 git add 파일이름

 

1-2 git commit -m "메시지 입력" 

 

 

 

5. git 명령어 모음 

 

git checkout HEAD~
커서(HEAD)를 이전 commit 으로 이동 (~갯수만큼 뒤로감)

git status
git 현재 저장소의 상태 확인

git log
git 변경 이력 확인

 

git add

변경 사항을 staging area (Index)에 올리기

 

git commit -m "메세지"

staging area 에 있는 내용을 commit 하기 

 

git branch 브랜치명

새로운 branch 만들기

 

git branch

branch 목록 보기

 

git checkout 브랜치명

branch 이동

 

git merge 브랜치명

branch 합치기

 

git branch -d 브랜치명

branch 삭제

 

git reset (옵션) HEAD~

commit 취소하기

옵션 : 

--hard : working dir, staging area, commit 모두 취소

--soft : commit 취소

--mixed : staging area, commit 취소

 

git reflog

이전 작업 목록로그 확인

 

작업하던 내용 임시 저장 및 관리

 

git stash save 

추적되지 않는 파일을 제외하고 변경사항 저장

 

git  stash  save  -u

추적되지 않는 파일도 포함해서 변경사항 저장

 

git  stash  pop 

저장된 변경사항을 지우면서 적용 시키기

 

git  stash  apply  [ stash id ]

저장된 변경사항을 유지하면서 적용 시키기

 

git  stash  drop  [ stash id ]

저장된 변경사항을 삭제하기

 

git  stash  list

저장된 변경사항 목록 보기 

 

추적하고 있는(commit 한적이 있는 파일) 파일에 대한 변경 사항 복구(취소)하기

 

git  restore  파일명

특정 파일만 복구 (add 된 파일은 복구가 안된다)

 

git  restore

모든 파일 복구  (add 된 파일은 복구가 안된다)

 

git  restore --staged  파일명

특정 파일 add 취소

 

기존 github 저장소를 내 로컬로 복제
git clone (git 저장소의 URL)

 

'Git' 카테고리의 다른 글

[Eclipse] Git Hub clone 코드 사용하기  (0) 2023.05.11
[Eclipse] Git Hub 연동 및 푸쉬  (0) 2023.05.10
Git Hub fetch, pull  (0) 2023.04.24
GitHub Repositories 연동 및 push  (0) 2023.04.19