December 11, 2018

git(distributed version control system)


The software for source code configuration management.
소스코드 형상관리 목적의 소프트웨어.




1. Feature  특징
01. It saves the changes using a snapshot rather than saving differences.
데이터의 변경사항을 차분 방식으로 저장하지 않고, 스냅샷 방식으로 저장.
02. It encrypts the data and manages it using checksum.
데이터는 암호화되며 체크섬을 이용하여 관리.
03. It can also manage data locally.
로컬에서도 데이터 관리 가능.
04. Multiple people can independently modify data.
여러 사람이 각자 독립적으로 데이터 수정 가능.


2. How to install  설치 방법
01. Linux.
# apt-get install git


3. How to use  사용법
❑ Download(clone) a git project.
git 프로젝트 다운로드(복제).
$ git clone [project path]

The copy of the project is created in the current directory.
현재 디렉토리에 프로젝트의 복사본이 생긴다.


❑ Check the commit log.
커밋 로그 확인.
bandit28@bandit:/tmp/mytmp56/repo/.git$ git log --all
commit 073c27c130e6ee407e12faad1dd3848a110c4f95
Author: Morla Porla <morla@overthewire.org>
Date:   Tue Oct 16 14:00:39 2018 +0200

    fix info leak

commit 186a1038cc54d1358d42d468cdc8e3cc28a93fcb
Author: Morla Porla <morla@overthewire.org>
Date:   Tue Oct 16 14:00:39 2018 +0200

    add missing data

commit b67405defc6ef44210c53345fc953e6a21338cc7
Author: Ben Dover <noone@overthewire.org>
Date:   Tue Oct 16 14:00:39 2018 +0200

    initial commit of README.md

Many git related commands require the place where the ".git" folder is visible.
git 관련 명령어는 대체로 ".git" 폴더가 보이는 곳에서 실행해야 동작한다.

* commit: This is similar to the intermediate save before uploading to the server.
* 커밋: 서버에 업로드 전 중간 저장 비슷한 것.


❑ Check the commit contents.
커밋 내용 확인.
bandit28@bandit:/tmp/mytmp56/repo/.git$ git show [commit code | reference name]
commit 186a1038cc54d1358d42d468cdc8e3cc28a93fcb
Author: Morla Porla <morla@overthewire.org>
Date:   Tue Oct 16 14:00:39 2018 +0200

    add missing data

diff --git a/README.md b/README.md
index 7ba2d2f..3f7cee8 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ Some notes for level29 of bandit.
 ## credentials

 - username: bandit29
-- password: <TBD>
+- password: bbc96594b4e001778eee9975372716b2


❑ Check the branch list.
브랜치 확인.
bandit29@bandit:/tmp/mytmp59/repo$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/master
  remotes/origin/sploits-dev


❑ Select a branch.
브랜치 선택.
git checkout [branch path]

bandit29@bandit:/tmp/mytmp59/repo$ git checkout remotes/origin/dev
Previous HEAD position was 2af54c5... add some silly exploit, just for shit and giggles
HEAD is now at 33ce2e9... add data needed for development
bandit29@bandit:/tmp/mytmp59/repo$


❑ Check the reference list.
레퍼런스 확인.
bandit30@bandit:/tmp/mytmp2930/repo$ git show-ref
3aa4c239f729b07deb99a52f125893e162daac9e refs/heads/master
3aa4c239f729b07deb99a52f125893e162daac9e refs/remotes/origin/HEAD
3aa4c239f729b07deb99a52f125893e162daac9e refs/remotes/origin/master
f17132340e8ee6c159e0a4a6bc6f80e1da3b1aea refs/tags/secret

* Reference
- The information recorded in ".git/refs/" or ".git/packed-refs".
- It serves the role of naming the commit codes the same as the Branch.
- Branch is the logical name, and the Reference is the name on the file structure.

* 레퍼런스(Reference)
- ".git/refs/" 혹은 ".git/packed-refs"에 기록된 정보.
- 브랜치와 동일하게 커밋에 네이밍을 하는 역할을 한다.
- 브랜치가 논리적 명칭이라면, 레퍼런스는 파일 구조상의 명칭.


❑ add → commit → push.
bandit31@bandit:/tmp/tmp3132/repo$ echo "May I come in?" > ./key.txt
bandit31@bandit:/tmp/tmp3132/repo$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
bandit31@bandit:/tmp/tmp3132/repo$ git add -f ./key.txt
bandit31@bandit:/tmp/tmp3132/repo$ git commit -m "key added"
[master 07e056a] key added
 1 file changed, 1 insertion(+)
 create mode 100644 key.txt
bandit31@bandit:/tmp/tmp3132/repo$
bandit31@bandit:/tmp/tmp3132/repo$ git push origin master
Could not create directory '/home/bandit31/.ssh'.
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:98UL0ZWr85496EtCRkKlo20X3OPnyPSB5tB5RPbhczc.

- Omission 생략 -