SlideShare uma empresa Scribd logo
1 de 100
Baixar para ler offline
Basic
Commands
insanehong@KGUG
2014. 12. 20
NAVER / NAVER LABS
twitter: @insanehong
email : insanehong@gmail.com
http://about.me/insanehong
insanehong.talk.start(“Hi! Bro!”)
이시간에 다루지 않을 것들
https://www.flickr.com/photos/miguelpdl/4994396370
이시간에 전달하려고 하는 것들
기본적인 사용법 & 개념
내부 동작 원리
주의! 이 교육은 간접 광고를 포함하고 있지 않습니다.
http://www.dailycal.org/2013/11/21/everybody-macbook/
Why do programmers
use or recommend
macs or linux?
http://www.dailycal.org/2013/11/21/everybody-macbook/
주의! 이 교육은 간접 광고를 포함하고 있지 않습니다.
& CLIGUI
Recommend
NAVER give up!!
e
이 교육은 간접 광고를 절대 포함하고 있지 않습니다.
photo by https://www.flickr.com/photos/slworking/
Try git better, together
우리 모두는 A사 입사를 위해
퀴즈를 풀어 제출해야 합니다.
채용 퀴즈
“같은 문자가 연속적으로 반복되는 경우에 그 반복 횟수를
표시하여 문자열을 압축하기”
제출 방법
• recruiting@a.com 으로 github url 제출
• 첨부파일로는 받지 않습니다.
Great a Git repository
git init
“This command creates an empty git repository”
- https://www.kernel.org/pub/software/scm/git/docs/git-init.html -
• 현재 디렉토리를 git 저장소로 만들 때
$> git init
• 새로운 디렉토리를 만들때
$> git init <directory>
/workspace
$> git init git-study && cd git-study
Initialized empty Git repository /workspace/git-study/.git/
/git-study
.git└─
/git-study
.git└─
Repository Structure
Working
tree
index
(Staging area)
object
database
Working
area
Cache
storage
Storage
Working
tree
index
(Staging area)
object
database
git add git commit
여기서 잠깐!
What is commit?
“In computer science and data management,
a commit is the making of a set of tentative
changes permanent.”
- http://en.wikipedia.org/wiki/Commit_(data_management) -
“특정 시점에 대한
스냅샷 혹은 상태”
Git 사용한다는 것?
Git 으로 commit 을 다루는것!
Untracked Staged Committed Modified
Tracked
git add git commit edit file
git add
file
Be committed to doing
/git-study
.git├─
compress.js└─
│
http://git.io/Tq59Hw
Working
tree
index
(Staging area)
object
database
git add git commit
git add
“This command updates the index using
the current content found in the working tree,
to prepare the content staged for the next commit”
- https://www.kernel.org/pub/software/scm/git/docs/git-add.html -
“working directory 에서 변경되거나 추가된 파일들 중에서
커밋에 포함될 파일들을 등록해 놓는 것”
• 특정 파일들만을 지정
$> git add <file1> <file2>
• 변경되거나 추가된 모든 파일을 다룰때
$> git add -a
여기서 잠깐 Two!
변경 파일이 많거나 어떤 파일이
수정 되었는지 모를때는?
git status
“Displays paths that have differences between the index
file and the current HEAD commit, and paths in the
working tree that are not tracked by git”
- https://www.kernel.org/pub/software/scm/git/docs/git-status.html -
“Woking directory 의 상태를 보여준다. ”
• 자세한 내용을 확인 할때
$> git status
• 파일들의 변경 상태만 확인 할때
$> git status -s
$> git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
compress.js
nothing added to commit but untracked files present
(use "git add" to track)
$> git status -s
?? compress.js
/git-study
.git├─
compress.js└─
│
$> git add compress.js
$> git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: compress.js
$> git status -s
A compress.js
Working
tree
index
(Staging area)
object
database
git add git commit
git commit
“Stores the current contents of the index in a
new commit along with a log message from the user
describing the changes.”
- https://www.kernel.org/pub/software/scm/git/docs/git-commit.html -
/git-study
.git├─
compress.js└─
│
$> git commit -m “문제풀이 완료”
[master (root-commit) 5525f5f] 문제풀이 완료
1 file changed, 28 insertions(+)
create mode 100644 compress.js
$> git status
On branch master
nothing to commit, working directory clean
5525f5f 문제풀이 완료
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
Untracked
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
blob
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
81b90e8
Staged
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
blob
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
tree
81b90e8
3cfa7a2
compress.js 81b90e8
commit 5525f5f
tree 3cfa7a2
author
insnae<insnae@mail>
1330482646 +0900
commiter
insnae<insnae@mail>
1330482646 +0900
문제풀이 완료
Commited
자 이제 코드를 제출하면 되나요?
$> node compress
hello world, hello git > hel2o world, hel2o git
helloooooooo > hel2o
제가 한번 실행해 보겠습니다!
https://www.flickr.com/photos/slworking/8739080572
이상한 점을 찾으셨나요?
“helloooooooo”> hel2o
currently
“helloooooooo”> hel2o8
Goals
8 if( str.charAt(i) === prev ) {
9 repeat++;
10 if ( i === str.length -1) result+=repeat;
11 } else {
Solution
8 if( str.charAt(i) === prev ) {
9 repeat++;
10 if ( i === str.length - 1 ) result += repeat;
11 } else {
• 버그 수정후 “버그 수정” 이란 메세지로 커밋
• header 추가 후 커밋 “헤더 추가” 란 메세지로 커밋
1 /*
2 Author insanehong <insanehong@gmail.com>
3 LICENSE under BSD
4 */
git diff
“Show changes between the working tree and
the index or a tree, changes between the index and
a tree, changes between two trees, or changes
between two files on disk..”
- https://www.kernel.org/pub/software/scm/git/docs/git-diff.html -
• working directory 와 index 를 비교
$> git diff
• 커밋 간 차이점 을 비교
$> git diff <commitA>..<commitB>
• index 와 HEAD를 비교
$> git diff --staged
/git-study
.git├─
compress.js└─
│
$> git diff
diff --git a/compress.js b/compress.js
index 81b90e8..46c3d6e 100644
--- a/compress.js
+++ b/compress.js
@@ -7,6 +7,7 @@ function compress(str) {
if( str.charAt(i) === prev ) {
repeat++;
+ if ( i === str.length -1) result+=repeat;
} else {
if (repeat > 1) result+=repeat;
result+=str.charAt(i);
5525f5f 문제풀이 완료
/git-study
.git├─
compress.js└─
│ $> git add compress.js
$> git status -s
M compress.js
$> git commit -m “버그수정”
[master f5cd615] 버그 수정
1 file changed, 1 insertion(+)
5525f5f 문제풀이 완료
f5cd615 버그 수정
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result
+= repeat;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
blob
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
tree
81b90e8
3cfa7a2
compress.js 81b90e8
commit 5525f5f
tree 3cfa7a2
author
insnae<insnae@mail>
1330482646 +0900
commiter
insnae<insnae@mail>
1330482646 +0900
문제풀이 완료
Modified
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result
+= repeat;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result
+= repeat;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
blob
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result += repeat;
} e
b3bddc
commit
81b90e8
tree
3cfa7a2
blob
81b90e8
Staged
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result
+= repeat;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
compress.js
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
var prev = result;
for( var i =1; i < str.length; i++ ) {
if( str.charAt(i) === prev ) {
repeat++;
if ( i === str.length - 1 ) result
+= repeat;
} else {
if (repeat > 1) result += repeat;
result += str.charAt(i);
repeat = 1;
}
prev = str.charAt(i);
}
console.log(str, ' > ', result);
}
var test1 = "hello world, hello git";
var test2 = "helloooooooo";
compress(test1);
compress(test2);
commit
81b90e8
tree
3cfa7a2
blob
81b90e8
commit
f5cd61
tree
1b3d8b
blob
b3bddc
Commited
/git-study
.git├─
compress.js└─
│ $> git add compress.js
$> git status -s
M compress.js
$> git commit -m “헤더 추가”
[master b6f9dc3] 헤더 추가
1 file changed, 4 insertions(+)
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
Commit inspection
git log
“Shows the commit logs.”
- https://www.kernel.org/pub/software/scm/git/docs/git-log.html -
• 현재 저장소의 시간순 커밋 히스토리 

$> git log
• diff 를 함께 보기
$> git log —p
• 커밋 메세지 조회
$> git log --grep <검색어>
$> git log
commit b6f9dc38625689032f6172bef905ae0a2aeebaa0
Author: insanehong <insanehong@gmail.com>
Date: Sat Dec 20 00:00:47 2014 +0900
헤더 추가
commit f5cd615c4643dce328fe56e291a16c43ef9c3a77
Author: insanehong <insanehong@gmail.com>
Date: Fri Dec 19 23:54:00 2014 +0900
버그 수정
commit 5525f5f0b8945c342a489ab1ff72469e5745a33e
Author: insanehong <insanehong@gmail.com>
Date: Fri Dec 19 23:18:42 2014 +0900
문제풀이 완료
$> git log --grep "버그"
commit f5cd615c4643dce328fe56e291a16c43ef9c3a77
Author: insanehong <insanehong@gmail.com>
Date: Fri Dec 19 23:54:00 2014 +0900
버그 수정
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
git show
“Shows one or more objects
(blobs, trees, tags and commits)”
- https://www.kernel.org/pub/software/scm/git/docs/git-show.html -
$> git show
commit b6f9dc38625689032f6172bef905ae0a2aeebaa0
Author: insanehong <insanehong@gmail.com>
Date: Sat Dec 20 00:00:47 2014 +0900
헤더 추가
diff --git a/compress.js b/compress.js
index 46c3d6e..cfdcf63 100644
--- a/compress.js
+++ b/compress.js
@@ -1,3 +1,7 @@
+/*
+Author insanehong <insanehong@gmail.com>
+*/
+
function compress(str) {
var repeat = 1;
var result = str.charAt(0);
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
Push to remote repository
bare
None-bare
None-bare
None-bare
Github
Local repo
Local repo
Local repo
git remote
“Manage the set of repositories ("remotes")
whose branches you track.”
- https://www.kernel.org/pub/software/scm/git/docs/git-remote.html -
• 원격 저장소 추가 

$> git remote add <alias> <url>
• 원격 저장소 alias 변경
$> git remote rename <old> <new>
• 원격 저장소 url 변경
$> git remote set-url <alias> <url>
• 원격 저장소 확인
$> git remote -v
$> git remote add origin git@github.com:insanehong/git-study.git
$> git remote -v
origin https://github.com/insanehong/git-repo.git (fetch)
origin https://github.com/insanehong/git-repo.git (push)
.git
config└─
git push
“Updates remote refs using local refs, while sending
objects necessary to complete the given refs.”
- https://www.kernel.org/pub/software/scm/git/docs/git-push.html -
$> git push origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (9/9), 965 bytes | 0 bytes/s, done.
Total 9 (delta 2), reused 0 (delta 0)
To git@github.com:insanehong/git-study.git
* [new branch] master -> master
/git-study
.git├─
compress.js└─
│
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
• README.md 파일 추가 후 원격저장소로 push
• commit message : “README 추가”
1 Compress.js
2 —-
3
4 같은 문자가 연속적으로 반복되는 경우에 그 반복 횟수를 표시하여 문자열 압축하기
/git-study
.git├─
compress.js└─
│
README.md└─
$> git add READMD.md
$> git commit -m “READMD 추가”
[master 650b6d7] READMD.md 추가
1 file changed, 4 insertions(+)
create mode 100644 README.md
$> git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 416 bytes |
0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:insanehong/git-study.git
b6f9dc3..650b6d7 master -> master
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
650b6d7 READMD 추가
Tips
• refs : object의 SHA-1 값을 저장한 파일들, ./git/refs 하위 모든 파일
• branch : 어떤 작업들 중 마지막 작업을 가리키는 레퍼런스
• branch name : branch 의 last commit 에 대한 alias (master)
• HEAD : 현재 checkout 되어 있는 커밋을 가리키는 레퍼런스
• tag : 특정 commit 을 가리키는 object
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
master branch
master HEAD650b6d7 READMD 추가
git reset
“This form resets the current branch head to <commit>
and possibly updates the index (resetting it to the tree of
<commit>) and the working tree depending on <mode>. If
<mode> is omitted, defaults to "--mixed". The <mode>
must be one of the following:”
- https://www.kernel.org/pub/software/scm/git/docs/git-reset.html -
• Working tree 를 유지하며 되돌리기 

$> git reset <commit>, --mixed
• Working tree, index 를 유지하며 되돌리기 

$> git reset --soft <commit>
• 모두 되돌리기
$> git reset --hard <commit>
$> git reset b6f9dc3
$> git status -s
?? README.md
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가 master HEAD
650b6d7 READMD
$> git reset --soft f5cd615
$> git status -s
M compress.js
?? README.md
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3
master HEAD
650b6d7 READMD
$> git reset --hard 650b6d7
HEAD is now at 650b6d7 READMD 추가
$> git status
On branch master
nothing to commit, working directory clean
5525f5f 문제풀이 완료
f5cd615 버그 수정
b6f9dc3 헤더 추가
master HEAD650b6d7 READMD 추가
git clone
“Clones a repository into a newly created directory,
creates remote-tracking branches for each branch in the
cloned repository, and creates and checks out an initial
branch that is forked from the cloned repository’s
currently active branch.”
- https://www.kernel.org/pub/software/scm/git/docs/git-clone.html -
“다른 프로젝트에 참여하거나(Contribute)
Git 저장소를 복사하고 싶을 때 사용.”
• remote 받아오기 

$> git clone <url>
• 디렉토리를 생성하면서 remote 받아오기 

$> git clone <url> <directory>
• remote 의 특정 branch 를 지정

$> git clone <url> -b <branch>
/git-study
.git├─
compress.js└─
│
README.md└─
Github
https://github.com/insanehong/git-study.git
/workspace/
$> git clone git@github.com:insanehong/git-study.git git-study-2
Cloning into 'git-study-2'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 12 (delta 2), reused 12 (delta 2)
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (2/2), done.
Checking connectivity... done.
$> cd git-study-2
git-study└─
/git-study-2
.git├─
compress.js└─
│
README.md└─
/workspace/
git-study
└─
├─
• git stash
• git blame
• git checkout
• git bisect
• git ls-files
• git fetch
• git merge
• git rebase
• git pull
• git rm
• git mv
http://www.flickr.com/photos/adulau/8442476626/
insanehong.talk.end(“Thanks. Bye!!”)
Git is a just tool!
• http://git-scm.com/book/ko/v1
• https://www.kernel.org/pub/software/scm/git/
• Thanks toYi Eung Jun at NAVER LABS (http://npcode.com)
• 본자료에 사용된 commit internal 부분은Yi Eung Jun 님의 git basic 강의 자료를 참고 했습니다.
Reference
Git is a just tool!
본 자료는 14.12.20 KGUG(Korea Git User Group) 주최 대학생 대상 Git 교육인
“Getting Started with git” 에서 발표된 “Git Basic Commands” 의 발표내용을 담고 있습니다.
본 자료는 크리에이티브 커먼즈 저작자표시-비영리-변경금지(CC BY-NC-ND) 3.0 Unported 라이선스
에 따라 이용할 수 있습니다.
본 자료에 사용 된 이미지들은 Creative Common License 를 따르며 이미지 출처는 해당 이미지 하단에
기제 되어 있습니다.
twitter : @insanehong
email : insanehong@gmail.com

Mais conteúdo relacionado

Mais procurados

Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션
Dabi Ahn
 
버전관리시스템 종류와 소개
버전관리시스템 종류와 소개버전관리시스템 종류와 소개
버전관리시스템 종류와 소개
Jong-il Seok
 
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
민태 김
 

Mais procurados (20)

git, 이해부터 활용까지
git, 이해부터 활용까지git, 이해부터 활용까지
git, 이해부터 활용까지
 
11. git basic
11. git basic11. git basic
11. git basic
 
Advanced git
Advanced gitAdvanced git
Advanced git
 
[NDC16] Effective Git
[NDC16] Effective Git[NDC16] Effective Git
[NDC16] Effective Git
 
Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션
 
초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHub초보자를 위한 Git & GitHub
초보자를 위한 Git & GitHub
 
Git 사용 가이드
Git 사용 가이드Git 사용 가이드
Git 사용 가이드
 
Git & Github Seminar-2
Git & Github Seminar-2Git & Github Seminar-2
Git & Github Seminar-2
 
[기초] GIT 교육 자료
[기초] GIT 교육 자료[기초] GIT 교육 자료
[기초] GIT 교육 자료
 
Git - Level 2
Git - Level 2Git - Level 2
Git - Level 2
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
Git 기본 가이드
Git 기본 가이드Git 기본 가이드
Git 기본 가이드
 
Git
GitGit
Git
 
Git
GitGit
Git
 
버전관리시스템 종류와 소개
버전관리시스템 종류와 소개버전관리시스템 종류와 소개
버전관리시스템 종류와 소개
 
Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)
 
Git & Github Seminar-1
Git & Github Seminar-1Git & Github Seminar-1
Git & Github Seminar-1
 
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+githubGit 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
 
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
 
Git 분산버전관리 시스템(1)
Git 분산버전관리 시스템(1)Git 분산버전관리 시스템(1)
Git 분산버전관리 시스템(1)
 

Destaque

Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)
Peter Kofler
 

Destaque (20)

Launching containers with fleet
Launching containers with fleetLaunching containers with fleet
Launching containers with fleet
 
Sw install with_without_docker
Sw install with_without_dockerSw install with_without_docker
Sw install with_without_docker
 
FLTK Summer Course - Part VI - Sixth Impact - Exercises
FLTK Summer Course - Part VI - Sixth Impact - ExercisesFLTK Summer Course - Part VI - Sixth Impact - Exercises
FLTK Summer Course - Part VI - Sixth Impact - Exercises
 
Servicios web con Python
Servicios web con PythonServicios web con Python
Servicios web con Python
 
Git hooks For PHP Developers
Git hooks For PHP DevelopersGit hooks For PHP Developers
Git hooks For PHP Developers
 
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
 
FLTK Summer Course - Part VII - Seventh Impact
FLTK Summer Course - Part VII  - Seventh ImpactFLTK Summer Course - Part VII  - Seventh Impact
FLTK Summer Course - Part VII - Seventh Impact
 
Using Git on the Command Line
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command Line
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2
 
Creating Custom Drupal Modules
Creating Custom Drupal ModulesCreating Custom Drupal Modules
Creating Custom Drupal Modules
 
FLTK Summer Course - Part III - Third Impact
FLTK Summer Course - Part III - Third ImpactFLTK Summer Course - Part III - Third Impact
FLTK Summer Course - Part III - Third Impact
 
TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and Reports
 
"Git Hooked!" Using Git hooks to improve your software development process
"Git Hooked!" Using Git hooks to improve your software development process"Git Hooked!" Using Git hooks to improve your software development process
"Git Hooked!" Using Git hooks to improve your software development process
 
FLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second ImpactFLTK Summer Course - Part II - Second Impact
FLTK Summer Course - Part II - Second Impact
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
FLTK Summer Course - Part II - Second Impact - Exercises
FLTK Summer Course - Part II - Second Impact - Exercises FLTK Summer Course - Part II - Second Impact - Exercises
FLTK Summer Course - Part II - Second Impact - Exercises
 
Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)
 
FLTK Summer Course - Part VIII - Eighth Impact
FLTK Summer Course - Part VIII - Eighth ImpactFLTK Summer Course - Part VIII - Eighth Impact
FLTK Summer Course - Part VIII - Eighth Impact
 
Manipulating file in Python
Manipulating file in PythonManipulating file in Python
Manipulating file in Python
 
FLTK Summer Course - Part I - First Impact - Exercises
FLTK Summer Course - Part I - First Impact - ExercisesFLTK Summer Course - Part I - First Impact - Exercises
FLTK Summer Course - Part I - First Impact - Exercises
 

Semelhante a Basic git-commands

헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
zupet
 
Javascript개발자의 눈으로 python 들여다보기
Javascript개발자의 눈으로 python 들여다보기Javascript개발자의 눈으로 python 들여다보기
Javascript개발자의 눈으로 python 들여다보기
지수 윤
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
Heo Seungwook
 
파이썬 스터디 15장
파이썬 스터디 15장파이썬 스터디 15장
파이썬 스터디 15장
SeongHyun Ahn
 
Clean code
Clean codeClean code
Clean code
bbongcsu
 

Semelhante a Basic git-commands (20)

C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
 
Multi mechanize
Multi mechanizeMulti mechanize
Multi mechanize
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
 
Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나Front-end Development Process - 어디까지 개선할 수 있나
Front-end Development Process - 어디까지 개선할 수 있나
 
제 5회 Lisp 세미나 - 클로저 개발팀을 위한 지속적인 통합
제 5회 Lisp 세미나 - 클로저 개발팀을 위한 지속적인 통합제 5회 Lisp 세미나 - 클로저 개발팀을 위한 지속적인 통합
제 5회 Lisp 세미나 - 클로저 개발팀을 위한 지속적인 통합
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택
 
Javascript개발자의 눈으로 python 들여다보기
Javascript개발자의 눈으로 python 들여다보기Javascript개발자의 눈으로 python 들여다보기
Javascript개발자의 눈으로 python 들여다보기
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
 
ffmpeg optimization using CUDA
ffmpeg optimization using CUDAffmpeg optimization using CUDA
ffmpeg optimization using CUDA
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
20150212 c++11 features used in crow
20150212 c++11 features used in crow20150212 c++11 features used in crow
20150212 c++11 features used in crow
 
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개[Pgday.Seoul 2018]  PostgreSQL 11 새 기능 소개
[Pgday.Seoul 2018] PostgreSQL 11 새 기능 소개
 
파이썬 스터디 15장
파이썬 스터디 15장파이썬 스터디 15장
파이썬 스터디 15장
 
Git: A Motivating Introduction
Git: A Motivating IntroductionGit: A Motivating Introduction
Git: A Motivating Introduction
 
DEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptxDEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptx
 
웹개발자가 알아야할 기술
웹개발자가 알아야할 기술웹개발자가 알아야할 기술
웹개발자가 알아야할 기술
 
스프링처럼 JDBC 리팩터링하기
스프링처럼 JDBC 리팩터링하기 스프링처럼 JDBC 리팩터링하기
스프링처럼 JDBC 리팩터링하기
 
Clean code
Clean codeClean code
Clean code
 
[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?[143] Modern C++ 무조건 써야 해?
[143] Modern C++ 무조건 써야 해?
 

Basic git-commands

  • 2. NAVER / NAVER LABS twitter: @insanehong email : insanehong@gmail.com http://about.me/insanehong insanehong.talk.start(“Hi! Bro!”)
  • 6. 기본적인 사용법 & 개념 내부 동작 원리
  • 7. 주의! 이 교육은 간접 광고를 포함하고 있지 않습니다. http://www.dailycal.org/2013/11/21/everybody-macbook/
  • 8. Why do programmers use or recommend macs or linux? http://www.dailycal.org/2013/11/21/everybody-macbook/ 주의! 이 교육은 간접 광고를 포함하고 있지 않습니다.
  • 10. NAVER give up!! e 이 교육은 간접 광고를 절대 포함하고 있지 않습니다. photo by https://www.flickr.com/photos/slworking/
  • 11. Try git better, together
  • 12. 우리 모두는 A사 입사를 위해 퀴즈를 풀어 제출해야 합니다.
  • 13. 채용 퀴즈 “같은 문자가 연속적으로 반복되는 경우에 그 반복 횟수를 표시하여 문자열을 압축하기” 제출 방법 • recruiting@a.com 으로 github url 제출 • 첨부파일로는 받지 않습니다.
  • 14. Great a Git repository
  • 15. git init “This command creates an empty git repository” - https://www.kernel.org/pub/software/scm/git/docs/git-init.html -
  • 16. • 현재 디렉토리를 git 저장소로 만들 때 $> git init • 새로운 디렉토리를 만들때 $> git init <directory>
  • 17. /workspace $> git init git-study && cd git-study Initialized empty Git repository /workspace/git-study/.git/
  • 25. “In computer science and data management, a commit is the making of a set of tentative changes permanent.” - http://en.wikipedia.org/wiki/Commit_(data_management) -
  • 28. Git 으로 commit 을 다루는것!
  • 29. Untracked Staged Committed Modified Tracked git add git commit edit file git add file
  • 34. git add “This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit” - https://www.kernel.org/pub/software/scm/git/docs/git-add.html -
  • 35. “working directory 에서 변경되거나 추가된 파일들 중에서 커밋에 포함될 파일들을 등록해 놓는 것”
  • 36. • 특정 파일들만을 지정 $> git add <file1> <file2> • 변경되거나 추가된 모든 파일을 다룰때 $> git add -a
  • 38. 변경 파일이 많거나 어떤 파일이 수정 되었는지 모를때는?
  • 39. git status “Displays paths that have differences between the index file and the current HEAD commit, and paths in the working tree that are not tracked by git” - https://www.kernel.org/pub/software/scm/git/docs/git-status.html -
  • 40. “Woking directory 의 상태를 보여준다. ”
  • 41. • 자세한 내용을 확인 할때 $> git status • 파일들의 변경 상태만 확인 할때 $> git status -s
  • 42. $> git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) compress.js nothing added to commit but untracked files present (use "git add" to track) $> git status -s ?? compress.js
  • 43. /git-study .git├─ compress.js└─ │ $> git add compress.js $> git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: compress.js $> git status -s A compress.js
  • 45. git commit “Stores the current contents of the index in a new commit along with a log message from the user describing the changes.” - https://www.kernel.org/pub/software/scm/git/docs/git-commit.html -
  • 46. /git-study .git├─ compress.js└─ │ $> git commit -m “문제풀이 완료” [master (root-commit) 5525f5f] 문제풀이 완료 1 file changed, 28 insertions(+) create mode 100644 compress.js $> git status On branch master nothing to commit, working directory clean 5525f5f 문제풀이 완료
  • 47. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); Untracked
  • 48. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); blob function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; 81b90e8 Staged
  • 49. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); blob function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; tree 81b90e8 3cfa7a2 compress.js 81b90e8 commit 5525f5f tree 3cfa7a2 author insnae<insnae@mail> 1330482646 +0900 commiter insnae<insnae@mail> 1330482646 +0900 문제풀이 완료 Commited
  • 50. 자 이제 코드를 제출하면 되나요?
  • 51. $> node compress hello world, hello git > hel2o world, hel2o git helloooooooo > hel2o 제가 한번 실행해 보겠습니다!
  • 55. 8 if( str.charAt(i) === prev ) { 9 repeat++; 10 if ( i === str.length -1) result+=repeat; 11 } else { Solution
  • 56. 8 if( str.charAt(i) === prev ) { 9 repeat++; 10 if ( i === str.length - 1 ) result += repeat; 11 } else { • 버그 수정후 “버그 수정” 이란 메세지로 커밋 • header 추가 후 커밋 “헤더 추가” 란 메세지로 커밋 1 /* 2 Author insanehong <insanehong@gmail.com> 3 LICENSE under BSD 4 */
  • 57. git diff “Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, or changes between two files on disk..” - https://www.kernel.org/pub/software/scm/git/docs/git-diff.html -
  • 58. • working directory 와 index 를 비교 $> git diff • 커밋 간 차이점 을 비교 $> git diff <commitA>..<commitB> • index 와 HEAD를 비교 $> git diff --staged
  • 59. /git-study .git├─ compress.js└─ │ $> git diff diff --git a/compress.js b/compress.js index 81b90e8..46c3d6e 100644 --- a/compress.js +++ b/compress.js @@ -7,6 +7,7 @@ function compress(str) { if( str.charAt(i) === prev ) { repeat++; + if ( i === str.length -1) result+=repeat; } else { if (repeat > 1) result+=repeat; result+=str.charAt(i); 5525f5f 문제풀이 완료
  • 60. /git-study .git├─ compress.js└─ │ $> git add compress.js $> git status -s M compress.js $> git commit -m “버그수정” [master f5cd615] 버그 수정 1 file changed, 1 insertion(+) 5525f5f 문제풀이 완료 f5cd615 버그 수정
  • 61. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); blob function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; tree 81b90e8 3cfa7a2 compress.js 81b90e8 commit 5525f5f tree 3cfa7a2 author insnae<insnae@mail> 1330482646 +0900 commiter insnae<insnae@mail> 1330482646 +0900 문제풀이 완료 Modified
  • 62. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); blob if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } e b3bddc commit 81b90e8 tree 3cfa7a2 blob 81b90e8 Staged
  • 63. compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); compress.js function compress(str) { var repeat = 1; var result = str.charAt(0); var prev = result; for( var i =1; i < str.length; i++ ) { if( str.charAt(i) === prev ) { repeat++; if ( i === str.length - 1 ) result += repeat; } else { if (repeat > 1) result += repeat; result += str.charAt(i); repeat = 1; } prev = str.charAt(i); } console.log(str, ' > ', result); } var test1 = "hello world, hello git"; var test2 = "helloooooooo"; compress(test1); compress(test2); commit 81b90e8 tree 3cfa7a2 blob 81b90e8 commit f5cd61 tree 1b3d8b blob b3bddc Commited
  • 64. /git-study .git├─ compress.js└─ │ $> git add compress.js $> git status -s M compress.js $> git commit -m “헤더 추가” [master b6f9dc3] 헤더 추가 1 file changed, 4 insertions(+) 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가
  • 66. git log “Shows the commit logs.” - https://www.kernel.org/pub/software/scm/git/docs/git-log.html -
  • 67. • 현재 저장소의 시간순 커밋 히스토리 
 $> git log • diff 를 함께 보기 $> git log —p • 커밋 메세지 조회 $> git log --grep <검색어>
  • 68. $> git log commit b6f9dc38625689032f6172bef905ae0a2aeebaa0 Author: insanehong <insanehong@gmail.com> Date: Sat Dec 20 00:00:47 2014 +0900 헤더 추가 commit f5cd615c4643dce328fe56e291a16c43ef9c3a77 Author: insanehong <insanehong@gmail.com> Date: Fri Dec 19 23:54:00 2014 +0900 버그 수정 commit 5525f5f0b8945c342a489ab1ff72469e5745a33e Author: insanehong <insanehong@gmail.com> Date: Fri Dec 19 23:18:42 2014 +0900 문제풀이 완료 $> git log --grep "버그" commit f5cd615c4643dce328fe56e291a16c43ef9c3a77 Author: insanehong <insanehong@gmail.com> Date: Fri Dec 19 23:54:00 2014 +0900 버그 수정 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가
  • 69. git show “Shows one or more objects (blobs, trees, tags and commits)” - https://www.kernel.org/pub/software/scm/git/docs/git-show.html -
  • 70. $> git show commit b6f9dc38625689032f6172bef905ae0a2aeebaa0 Author: insanehong <insanehong@gmail.com> Date: Sat Dec 20 00:00:47 2014 +0900 헤더 추가 diff --git a/compress.js b/compress.js index 46c3d6e..cfdcf63 100644 --- a/compress.js +++ b/compress.js @@ -1,3 +1,7 @@ +/* +Author insanehong <insanehong@gmail.com> +*/ + function compress(str) { var repeat = 1; var result = str.charAt(0); 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가
  • 71. Push to remote repository
  • 74. git remote “Manage the set of repositories ("remotes") whose branches you track.” - https://www.kernel.org/pub/software/scm/git/docs/git-remote.html -
  • 75. • 원격 저장소 추가 
 $> git remote add <alias> <url> • 원격 저장소 alias 변경 $> git remote rename <old> <new> • 원격 저장소 url 변경 $> git remote set-url <alias> <url> • 원격 저장소 확인 $> git remote -v
  • 76. $> git remote add origin git@github.com:insanehong/git-study.git $> git remote -v origin https://github.com/insanehong/git-repo.git (fetch) origin https://github.com/insanehong/git-repo.git (push) .git config└─
  • 77. git push “Updates remote refs using local refs, while sending objects necessary to complete the given refs.” - https://www.kernel.org/pub/software/scm/git/docs/git-push.html -
  • 78. $> git push origin master Counting objects: 9, done. Delta compression using up to 4 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (9/9), 965 bytes | 0 bytes/s, done. Total 9 (delta 2), reused 0 (delta 0) To git@github.com:insanehong/git-study.git * [new branch] master -> master /git-study .git├─ compress.js└─ │ 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가
  • 79.
  • 80. • README.md 파일 추가 후 원격저장소로 push • commit message : “README 추가” 1 Compress.js 2 —- 3 4 같은 문자가 연속적으로 반복되는 경우에 그 반복 횟수를 표시하여 문자열 압축하기
  • 81. /git-study .git├─ compress.js└─ │ README.md└─ $> git add READMD.md $> git commit -m “READMD 추가” [master 650b6d7] READMD.md 추가 1 file changed, 4 insertions(+) create mode 100644 README.md $> git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 416 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@github.com:insanehong/git-study.git b6f9dc3..650b6d7 master -> master 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가 650b6d7 READMD 추가
  • 82. Tips
  • 83. • refs : object의 SHA-1 값을 저장한 파일들, ./git/refs 하위 모든 파일 • branch : 어떤 작업들 중 마지막 작업을 가리키는 레퍼런스 • branch name : branch 의 last commit 에 대한 alias (master) • HEAD : 현재 checkout 되어 있는 커밋을 가리키는 레퍼런스 • tag : 특정 commit 을 가리키는 object
  • 84. 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가 master branch master HEAD650b6d7 READMD 추가
  • 85. git reset “This form resets the current branch head to <commit> and possibly updates the index (resetting it to the tree of <commit>) and the working tree depending on <mode>. If <mode> is omitted, defaults to "--mixed". The <mode> must be one of the following:” - https://www.kernel.org/pub/software/scm/git/docs/git-reset.html -
  • 86. • Working tree 를 유지하며 되돌리기 
 $> git reset <commit>, --mixed • Working tree, index 를 유지하며 되돌리기 
 $> git reset --soft <commit> • 모두 되돌리기 $> git reset --hard <commit>
  • 87. $> git reset b6f9dc3 $> git status -s ?? README.md 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가 master HEAD 650b6d7 READMD
  • 88. $> git reset --soft f5cd615 $> git status -s M compress.js ?? README.md 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 master HEAD 650b6d7 READMD
  • 89. $> git reset --hard 650b6d7 HEAD is now at 650b6d7 READMD 추가 $> git status On branch master nothing to commit, working directory clean 5525f5f 문제풀이 완료 f5cd615 버그 수정 b6f9dc3 헤더 추가 master HEAD650b6d7 READMD 추가
  • 90. git clone “Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository, and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.” - https://www.kernel.org/pub/software/scm/git/docs/git-clone.html -
  • 91. “다른 프로젝트에 참여하거나(Contribute) Git 저장소를 복사하고 싶을 때 사용.”
  • 92. • remote 받아오기 
 $> git clone <url> • 디렉토리를 생성하면서 remote 받아오기 
 $> git clone <url> <directory> • remote 의 특정 branch 를 지정
 $> git clone <url> -b <branch>
  • 94. /workspace/ $> git clone git@github.com:insanehong/git-study.git git-study-2 Cloning into 'git-study-2'... remote: Counting objects: 12, done. remote: Compressing objects: 100% (7/7), done. remote: Total 12 (delta 2), reused 12 (delta 2) Receiving objects: 100% (12/12), done. Resolving deltas: 100% (2/2), done. Checking connectivity... done. $> cd git-study-2 git-study└─
  • 96. • git stash • git blame • git checkout • git bisect • git ls-files • git fetch • git merge • git rebase • git pull • git rm • git mv
  • 99. Git is a just tool! • http://git-scm.com/book/ko/v1 • https://www.kernel.org/pub/software/scm/git/ • Thanks toYi Eung Jun at NAVER LABS (http://npcode.com) • 본자료에 사용된 commit internal 부분은Yi Eung Jun 님의 git basic 강의 자료를 참고 했습니다. Reference
  • 100. Git is a just tool! 본 자료는 14.12.20 KGUG(Korea Git User Group) 주최 대학생 대상 Git 교육인 “Getting Started with git” 에서 발표된 “Git Basic Commands” 의 발표내용을 담고 있습니다. 본 자료는 크리에이티브 커먼즈 저작자표시-비영리-변경금지(CC BY-NC-ND) 3.0 Unported 라이선스 에 따라 이용할 수 있습니다. 본 자료에 사용 된 이미지들은 Creative Common License 를 따르며 이미지 출처는 해당 이미지 하단에 기제 되어 있습니다. twitter : @insanehong email : insanehong@gmail.com