도구를 차근차근 배우기에는시간이 많이 없어요
-‐-‐ main porcelain command -‐-‐
add -‐-‐ add file contents to index
am -‐-‐ apply patches from a mailbox
archive -‐-‐ create archive of files from named tree
bisect -‐-‐ find, by binary search, change that introduced a bug
branch -‐-‐ list, create, or delete branches
bundle -‐-‐ move objects and refs by archive
checkout -‐-‐ checkout branch or paths to working tree
cherry-‐pick -‐-‐ apply changes introduced by some existing commits
citool -‐-‐ graphical alternative to git commit
clean -‐-‐ remove untracked files from working tree
clone -‐-‐ clone repository into new directory
commit -‐-‐ record changes to repository
describe -‐-‐ show most recent tag that is reachable from a commit
diff -‐-‐ show changes between commits, commit and working tree, etc.
fetch -‐-‐ download objects and refs from another repository
format-‐patch -‐-‐ prepare patches for e-‐mail submission
gc -‐-‐ cleanup unnecessary files and optimize local repository
grep -‐-‐ print lines matching a pattern
gui -‐-‐ run portable graphical interface to git
init -‐-‐ create empty git repository or re-‐initialize an existing one
log -‐-‐ show commit logs
merge -‐-‐ join two or more development histories together
mv -‐-‐ move or rename file, directory, or symlink
notes -‐-‐ add or inspect object notes
pull -‐-‐ fetch from and merge with another repository or local branch
push -‐-‐ update remote refs along with associated objects
rebase -‐-‐ fasforward-‐port local commits to the updated upstream head
reset -‐-‐ reset current HEAD to specified state
revert -‐-‐ revert existing commits
rm -‐-‐ remove files from the working tree and from the index
shortlog -‐-‐ summarize git log output
show -‐-‐ show various types of objects
stash -‐-‐ stash away changes to dirty working directory
status -‐-‐ show working-‐tree status
submodule -‐-‐ initialize, update, or inspect submodules
tag -‐-‐ create, list, delete or verify tag object signed with GPG
http://www.insightforums.com/
how-to-educate-your-customers-and-win-fans-for-life/
10.
그래서
튜토리얼 등을 보다쉽게 소화하실 수 있도록,
당장 프로젝트에서 git을 아쉬운 대로 사용할 수 있도록
그리고 git을 쓰면 도대체 무엇이 좋은지
기능 보단 핵심 개념 위주로 간략히 짚어보도록 하겠습니다.
도대체 인덱스 개념은왜 있을까요?
• 원하는 부분만을 커밋하여, 하나의 커밋은 독립적인 하
나의 변화만을 포함해야 한다는 버전 관리의 원칙을
지킬 수 있도록 도와줍니다.
Issue #1: Implement an add function.
http://www.mfranc.com/uncategorized/git-git-gui-staging-selected-lines/
35.
도대체 인덱스 개념은왜 있을까요?
코드를 수정하다보면 같이 수정은 했는데 부득이하게
지금 커밋하기는 곤란한 일들이 생길 수 있어요.
만약 SVN이었다면,
- 현재 파일을 어디 다른 곳에 임시 백업해두고
- commit할 상태로 파일을 만들어서 커밋을 한 뒤
- 다시 백업해둔 파일로 복구해야 할거에요.아 귀찮아…
36.
귀찮아요.
인덱스를 생략하는 것도가능합니다.
• git commit -a 명령을 사용합니다.
• TortoiseGIT 등의 일부 클라이언트는 인덱스 개념이 없어서,
SVN처럼 바로 변경된 파일을 커밋하도록 만들어 놨어요.
브랜치 branches
저장소 이력의서로 다른 갈래 또는 분기.
• 아직 완료되지 않은 기능이라서 main 줄기에
반영하기는 좀 그런데 커밋과 이력 관리는 해
야할 때
• 1.3 버전 개발이 진행중인데 갑자기 1.2 버전
에서 발견된 버그를 핫픽스 해야할 때
• 두 명의 개발자가 서로 다른 기능을 동시에
독립적으로 개발하고 싶을 때
• …
40.
SVN에서는 디렉토리를 통째로복사하여 논리적으로 브
랜치를 운영할 수 있었습니다.
http://www.snipe.net/2009/03/getting-started-with-subversion-part-two/
히스토리를 봤을 때도브랜치가 언제 뻗어나와서
언제 어디로 머지되었는지가 명확하게 남습니다.
(이력 추적을 위해 blame 해보면 실제로 변경된 시점을 찾을 수 있어 편리합니다)
Merge branch ‘iss53’ into ‘master’
51.
한가지 중요한 일이남았습니다.
이제껏 로컬에 작업한 내용들을 서버에 업데이트하거나, 남
들과 코드를 공유하고 싶습니다.
52.
GIT 서버 저장소(remote repository)
내 저장소
git.mycompnay.com/project-‐a/test-‐repo.git
53.
각 개발자는 중앙저장소를 clone한 사본인
로컬 저장소(local repository)에서 작업합니다.
git clone
GIT 서버 저장소 (remote repository)
git.mycompany.com/project-‐a/test-‐repo.git
git clone git.mycompany.com/project-‐a/test-‐repo.git
54.
GIT 서버 저장소(remote repository)
이 때, 원격 저장소(origin)에 존재하는 브랜치들을
원격 브랜치(remote branch)라고 부르고, 구별하기 위해 로컬
저장소의 브랜치를 local branch라고 부릅니다.
‘origin/master’ 등의 이름으로 브랜치를 나타냅니다.
55.
이제 몇 가지작업을 진행해서 커밋을 추가합니다.
GIT 서버 저장소 (remote repository)
git.mycompany.com/project-‐a/test-‐repo.git
56.
어떤 브랜치를 원격저장소에 올리는 것을 푸시(push)라고 합니다.
GIT 서버 저장소 (remote repository)
git push origin master
git.mycompany.com/project-‐a/test-‐repo.git
57.
새로 추가한 커밋들이원격 저장소에도 추가되고,
원격 저장소의 master 브랜치가 앞으로 이동합니다.
git push origin master
58.
반대로 다른 사람이작업한 것을 받아올 수도 있습니다. (fetch)
git.mycompany.com/project-‐a/test-‐repo.git
git fetch origin
59.
중앙 GIT 저장소서버
git fetch origin
git.mycompany.com/project-‐a/test-‐repo.git
원격 저장소에 있는 커밋들과 브랜치를 가져오고,
origin/master 등의 remote branch가 이동(동기화)됩니다.
이 때 로컬 브랜치는 변화하지 않았습니다.
master 브랜치에, 'origin/master'브랜치를 merge합니다.
(git merge origin/master)
이 때,보통 아래와 같은 커밋 메시지가 만들어집니다.
Merge remote-tracking branch‘origin/master’ into ‘master’
67.
이렇게 합치고 난뒤, push 하면 됩니다.
이제 origin/master 브랜치의 입장에서는
fast-forward가 가능하므로 push가 성공합니다.
내가 추가했던 커밋을origin/master (fbff5) 뒤로 옮긴 다음에
master 브랜치를 push하면 fast-forward가 가능하겠죠?
75.
experiment 브랜치에서 작업하고있고, 커밋 C3은 C2에서 뻗어나왔
어요. experiment를 master로 rebase하여, C3 커밋을 C4 뒤에다가
얹고 싶습니다. ( (experiment)$ git rebase master )
Rebase란,브랜치의 base를 옮김으로써
커밋 히스토리를 다시 쓰는 작업입니다. 좀 더 자세히 살펴보아요.
76.
rebasing : experiment(C3)과master(C4)의 공통조상(C2)을 찾아,
experiment 브랜치에서 C2 이후의 커밋과 동일한 변경내역을 갖는 커밋을
master(C4)의 뒤에 만들어 달고 experiment 브랜치를 이동합니다.
experiment 브랜치를 master 브랜치 위에 rebase 합니다.
77.
여기서 C3' 은C3과는 (변경 내역과 커밋 메시지는 같지만)
다른 새로운 커밋입니다.(SHA-1 해시 ID가 다르다)
78.
• 공통점 :두 브랜치가 합쳐진 상태(커밋)를 만들어줍니다.
• merge
– 새로운 merge commit 을 만들되,
기존의 commit 객체들을 건드리지 않습니다.
• Rebase
– 기존의 수정 내용이 담긴 commit을‘복제’해서
다른 새로운 commi을 만들어줍니다.
– 따라서 History를 일직선으로 깔끔하게 유지할 수 있어요.
• 자세한 건 레퍼런스 참고 및 다음에…
rebase, merge 무엇이 다른가요?
79.
뭔 소린지 잘모르시겠다구요?
아직 push하지 않은 커밋이 있는데,이미 서버에
올라온 변경내역을 합쳐야 한다면
git pull --rebase 를 사용하면 좋습니다.
Pro Git :the official book
http://git-scm.com/book/ko
http://dogfeet.github.io/progit/progit.ko.pdf
여기에 수록된 많은 git 관련 그림들은 pro-git (git-scm.com/book)에서 발췌했습니다.