git clone https://github.com/libgit2/libgit2 MyProject

해당 주소의 깃 저장소를 자신의 로컬의 MyProject라는 디렉토리를 만들고 거기에 복제한다.

 

git commit -a

Tracked상태의 모든 파일을 Staging Area로 자동으로 올리고 commit한다.(Untracked상태는 안됨) 

example) git commit -a -m "message"

 

git log -p

commit log를 diff의 내용도 포함해서 보여준다.

 

git log --all

모든 브랜치에 대해서 커밋 로그를 보여준다.

 

git log --oneline


commit log를 간략히 한 줄로 보여준다.

 

git log --pretty=format:"%h - %an, %ar : %s"

commit log를 지정한 format형식으로 보여준다.

result)

ca82a6d - Scott Chacon, 6 years ago : changed the version number

085bb3b - Scott Chacon, 6 years ago : removed unnecessary test

a11bef0 - Scott Chacon, 6 years ago : first commit

 

git log --author SearchName

 

저자의 이름이 SearchName을 포함하고 있는 commit log만 보여준다.

 

git log --grep SerachWord

commit message에 SearchWord를 포함 하는 log만 보여준다.  

 

git log -S SearchCode​

코드의 변경사항에 SearchCode를 포함하고 있는 commit log만 보여준다.

 

git log -- path1 path2​

변경된 파일이 path1 또는 path2를 포함하고 있는 commit log만 보여준다.

 

git commit --amend​

Staging Area에 있는 내용을 추가하여 마지막 커밋을 수정한다.(커밋 메세지도 수정 가능)

 

git remote -v​

원격 저장소의 단축이름과 주소를 보여준다.

 

git remote add A RemoteAddress

RomoteAddress의 원격 저장소를 A라는 이름으로 추가한다.

 

git fetch [remote-name]

remote-name의 원격 저장소에 있는 데이터를 가져온다. 자동으로 Merge하지 않는다.

 

git push origin master

master브랜치를  origin이라는 이름을 가진 원격 저장소에 Push한다. 단 원격 저장소에 현재 자신의 로컬상태 이후로 Push한 사람이 없어야 가능하다.

 

git remote show [remote-name]

해당 원격저장소의 URL과 추적하는 브랜치를 출력한다.

 

git tag -a [tag-name] -m [tag-message]​

해당 이름과 해당 메세지로 Annotated 태그를 만든다.

 

git tag [tag-name]

해당 이름으로 Lightweight 태그를 만든다.

 

git push [remote-name] [tag-name]

해당 원격저장소에 해당 태그를 푸시한다.(git push 명령어로는 태그를 push하지 않음)

 

git push [remote-name] --tags

로컬에 있는 모든 태그(들)을 푸시한다.

 

git checkout -b [branch-name] [tag-name]​

해당 tag에서 해당 이름으로 새로운 브랜치를 생성한다.

 

git branch -d [branch-name]

해당 브랜치를 삭제한다.

git push [remote-name] :[remote-branch-name]

해당 원격 저장소의 해당 브랜치를 삭제한다.

 

git fetch [remote-name] -p

 

원격 저장소의 삭제된 브랜치를 반영하여 패치한다.

+ Recent posts