앞에는 명령어들만 나열

설명은 아래에


어차피 필자 본인 말고는 읽어도 이해가 잘 안될듯.


환경 : ubuntu linux


<command>

 - 환경 설정

sudo apt-get install git : git 설치

git config --global user.email "id@example.com"

git config --global user.name "ssaemo"


 - 저장소repository 설정 (Local)

<repository 만들기>

git init : local repository 생성

git status : 상태 확인

git add -A : ALL option

(git status)

git commit -m "first commit" : message option

(git status)

local repository를 삭제하고싶은 경우 : rm -rf ./.git


<repository 가져오기>

git clone URL

ex) git clone https://github.com/ssaemo/ubuntu_src.git


 - 저장소repository 설정 (Remote)

git remote (-v) : 해당 local repository에 등록된 remote repository 확인

git remote add 별명 URL : 아래에서 별명 origin, URL 설명

git push origin master : origin에 master branch push

username, password 입력

완료!



<설명>

git config --global : ~/.gitconfig 파일 수정. 해당 유저의 설정.

git config --system: /etc/gitconfig 파일 수정. 시스템 내 모든 사용자의 설정.

git config : ./.git/config 파일 수정. 해당 repository(저장소)의 설정.


origin : 별명 중 특별한 것으로, repository를 init이 아닌 clone 해왔을 경우, clone해온 remote repository가 자동으로 origin으로 등록된다.

remote repository URL : github.com를 예로 들면 repository를 만들고 들어가보면 우측에서 HTTPS clone URL을 확인할 수 있다. ex) https://github.com/ssaemo/ubuntu_src.git

master : repositry의 기본 branch. 필요에 따라 더 만들 수 있다. master 뿐이라면 master는 곧 repositry인 것이다.


<file 상태>

     파일 수정 -> Modified -> Staged -> Committed -> 파일 수정 -> 

working                                staging         local

directory                                area        repository

이후부터는 local repository에는 수정 전 상태가,

            working directory에는 수정 후 상태가 저장되어있다.


<구조>

working directory

staging area(index) : 가상 공간

local repository(HEAD) : 가상 공간

remote repository : ex)github

branch


<명령어 간단 이해>

commit을 snapshot이라고 생각하자.

staging(add)는 snapshot의 준비과정일 뿐이다.

push는 remote repository에 commit하는 것이다.


---


<그외 커맨드들>

git diff

 - 변경사항(changes)들을 stage(add) 하기전에 확인해보는 커맨드

 - 즉, stage되지 않은 changes를 출력


git reset [--soft | --mixed | --hard]

 - stage(add)된 변경사항들을 reset

 - ex) git reset --soft HEAD^


git submodule update --remote

 - submodule들을 latest version으로 update (github 등의 remote server로부터)



WRITTEN BY
hojongs
블로그 옮겼습니다 https://hojongs.github.io/