티스토리 뷰

Dev/기타

[Git] git 기초 요약

마이스토리 2018. 6. 21. 15:25
출처: 가천대 KMOOC git강좌
Git & Github (Git 강좌): http://www.youtube.com/watch?v=hWmk0iTLJJo&list=PLBHVuYlKEkULuUe_Ca3wiaFon6dPWIWAZ


<<git 설치>>
- http://git-scm.com

<<git 환경설정>>
> git config --global user.name "사용자이름"
> git config --global user.email "사용자이메일"

<<Local Repository>>
# .git 폴더생성됨(숨김폴더)
# 초기화: 작업할 workspace 폴더에서
> git init
# 상태조회
> git status
# 파일추가
> git add filename
# 커밋
> git commit [filename] -m "message"
 
# staged file vs committed file
# git 파일 상태 변화
-- 도식추가
# .gitignore 파일
- Tracking 하지 않을 파일 목록 기재
# git 파일 삭제
> git rm filename
# git 파일명 변경
> git mv filename newname
# git 로그 보기
> git log
> git log --stat //통계정보
> git log --pretty=oneline //한줄로
> git log --pretty=format:"%h -%an, %ar :%s " --graph

# 이번 버전으로 돌아가기
> git checkout 25df18 //버전해쉬주소 앞자리, not recommended
> git checkout master //branch 이름으로

# Branch
> git branch //branch 목록조회
> git branch new_branch_name //새 브랜치 만들기
> git checkout branch_name //해당 브랜치로 이동
> git merge other_branch_name //다른 브랜치와 합침
> gitk //브랜치 현황으로 그래프로 표시

<<Remote Repository?
# github
# remote repository 생성 후 로컬 repository 디렉토리에서 수행해야할 초기command 들
> echo "message" >> README.md
> git init
> git add README.md
> git commit -m "First commit"
> git remote add origin https://----.git //해당 주소의 리모트 레포지토리를 origin 이라는 이름으로 추가
> git push -u origin master //origin 리모트 레포지토리로 로그인하여 로컬 master 브랜치 소스를 업로드한다.

# remote 명령어
> git remote
> git remote -v
> git remote add origin(리모트명) https://----.git(리모트주소)
> git remote rm 리모트명

# remote --> local 가져오기
- Clone : 전체를 다 가져오는 명령
- Pull : 가져와서 같은 Branch를 합치는 명령
- Fetch : 변경 내용만 가져오고 안 합치는 명령

> git clone https://----.git [폴더명(옵션)]
> git pull origin master
> git fetch origin master
> git merge origin/master

<<공유하기>>
- Fork : 남의 github repository를 나의 github으로 가져오는 것.
- Pull & Request (PR) : Fork로 가져온 남의 소스를 수정한 후 가져다 달라고 요청하는 것.
--- 과정 도식 추가할 것,

# permission setting
github repository에 다른 사용자에게 권한을 주어 같은 repository에 바로 수정권한을 주는 것.

# merge
- 병합 작업은 툴로 처리하는 게 좋다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31