Git이란
1.Git의 역사
- 리눅스 커널 프로젝트를 위한 버전 관리 시스템으로 개발 (by 리눅스 토발스)
- Birth year : 2005년
2.Git vs SVN 트렌드 비교
3. Git의 초기 목표
- 속도 ( 네트워크 및 파일 처리 )
네트워크를 연결되지 않는 환경에서도 로컬에서 commit이 가능
로컬로 관리하다보니 속도가 빠름
파일처리는 해쉬알고리즘을 통해 이 파일이 변경되었는지 안되었는지 빠르게 판단.
- 동시 다발적인 개발
리눅스 커널은 세계에 있는 여러개발자들이 하나의 프로젝트를 개발하기 때문에
- 책임성
파일하에 대해서 누가 언제 변경했는지 추적이 가능함.
- 대형 프로젝트를 효율적으로 지원
리눅스는 65만번이상의 commit이 일어남.
5. Git의 브랜치 전략
동시에 병렬적으로 많은 브랜치가 생성되고 머지가 되어 하나의 프로젝트를 만듬.
동시에 병렬적으로 많은 브랜치가 생성이 되고 그 브랜치가 머지가 되며 하나의 제품이 만들어진다
브랜치의 생성과 삭제가 용이한 Git
브랜치 관리 전략중 하나 : Gitflow형태의 브랜치 관리전략
1) Master 브랜치 : Git을 생성하고 첫번째 Commit을 하는 곳
2) Hotfix : Master에서 파생되어오는 브랜치, 처음에 마스터 브랜치에서만 작업을하는 실수를 함
마스터 테이블은 언제든 릴리즈가 가능한 형태여야 하는데 작업중인 소스가 마스터에 올라가면, 작업이 완료되지 않은 소스를 다른 사람이 빋아 갈수 있음, 때문에 브랜치 관리 전략이 필요함
마스터에서 중요한 결함이나 에러가 발생 했을떄, 마스터에서 따고 핫픽스라는 버그에 대한 수정이 다되면 마스터에 마지 하게된다
3) Realse 브랜치 : Develop에서 파생되더 realse로 관리 되다가 master로 마지됨.
4) Develop 브랜치 : 실제적인 개발이 이루어지는 곳, 바로 master로 마지되는 경우는 없음.
5) Feature 브랜치 : 개발을 하다가 신규 기능이 발생했을떄 작업하다가 develop브랜치에 마지
하나의 Realse,Hotfix,Feature 폴더 밑에 여러 Realse,Hotfix,Feature 존재
여러 사람이 병렬적으로 작업하기 때문에 .
효율적으로 소스관리를 할수 있기 떄문에 좋은 브랜치 관리 전략인것 같습니다.
6. Git 동작 원리
1) Snapshot
- 데이터를 가져오거나 프로젝트를 저장할 떄 마다 그 시점의 파일에 대해서 스냅샷을 저장해 파일을 효율적으로 관리할 수 있게 도와줌
- 변경되지 않은 파일은 다시 파일을 저장하지 않고 이전에 지정한 동일한 파일을 링크함
파일을 복사하기 떄문에 저장공간을 사용하지 않음. 파일저장공간이 사이즈가 다른 버전관리 시스템에 비해 작은 특징을 가짐
2) Checksum
- 데이터를 저장하기 전에 파일에대한 체크섬을 구하고 이 체크섬을 통해 데이터를 관리
- 파일이 변경됬는지 안변경됬는지 확인하는 용도
- 파일이름이 아니라 컨탠츠의 해쉬값을 저장함
- 파일이름이 변경되도 내용이 같다면 같은 헤쉬가 나옴
- git에서는 파일이 이름이 바뀐건지 삭제하고 추가가 된건지 추적이 가능함.
- SHA-1 해쉬 사용
* 16진수 문자 40개로 구성된 문자열
commit 아이디 등에 사용
* 파일의 내용 또는 디렉토리 구조를 기반을고 계산
- 파일 이름이 아닌 컨텐츠의 해쉬 값을 저장
> 파일명이 변경되어도 내용이 동일하면 같은 해쉬
=================
2, Git 설치 및 설정
https://git-scm.com/downloads
3. 설정 파일 정보 확인
Git 에서는 책임성을 유지하기 위해 커밋한 사람의 이메일과 이름이 반드시 필요핟.
[설정 파일 위치]
1. 시스템 전역 경로 : C:\Program Files\Git\mingw64\etc\.gitconfig
2. USER_HOME/.gitconfig
3. Working 디렉토리 경로 /XXX/.git/config
우선순위 3>2>1을 우선으로 받아드림.
작업자 정보 입력
git config --global user.name mia
git config --global user.email miamhchoi@gmail.com
====================
git workflow
init 현재 디렉토리를 Git 레포지토리로 설정하는 명령 / 숨김 .git 디렉토리가 생성되면서 git을 실행할때 필요한 파일들이 생성됨
init설정 : Ignore 무시할 파일 설정
- OS에서 생성하는 파일, Log파일 등 관리할 필요가 없는 파일이 많습니다.
- 설정파일이 commit이 되는 경우를 막아야함으로.
그럼 관리를 해야하는 파일은?
- 프로젝트와 관련된 모든 파일
- 소스에 대한 설명이 들어있는 문서파일까지 같이 관리 해야함. 하나의 소스가 commit될때 문서도 같이 commit되야 올바르게 관리됨
- 이미지파일의 경우에도 경로에 관련된 이슈가 생길수 있으니 함께 commit!하는게 바른 관리
------명령어-------------
KST02@KST02 MINGW64 ~
$ mkdir git_ignore_test
KST02@KST02 MINGW64 ~
$ cd git_ignore_test/
KST02@KST02 MINGW64 ~/git_ignore_test
$ git init
Initialized empty Git repository in C:/Users/KST02/git_ignore_test/.git/
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ vim .gitignore
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ cat .gitignore
.DS_Store
*.log
*.iml
temp/
----ignore먹는지 확인해보기
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ touch .DS_Store
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ ls
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ ls -al
total 21
drwxr-xr-x 1 KST02 197121 0 10월 10 16:47 ./
drwxr-xr-x 1 KST02 197121 0 10월 10 16:42 ../
-rw-r--r-- 1 KST02 197121 0 10월 10 16:47 .DS_Store
drwxr-xr-x 1 KST02 197121 0 10월 10 16:40 .git/
-rw-r--r-- 1 KST02 197121 28 10월 10 16:42 .gitignore
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ echo "test" > test.html
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ ls -al
total 22
drwxr-xr-x 1 KST02 197121 0 10월 10 16:50 ./
drwxr-xr-x 1 KST02 197121 0 10월 10 16:42 ../
-rw-r--r-- 1 KST02 197121 0 10월 10 16:47 .DS_Store
drwxr-xr-x 1 KST02 197121 0 10월 10 16:40 .git/
-rw-r--r-- 1 KST02 197121 28 10월 10 16:42 .gitignore
-rw-r--r-- 1 KST02 197121 5 10월 10 16:50 test.html
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
test.html //DS_Store 안들어와 있음
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_ignore_test (master)
$
----
status
레포지토리의 상태를 보여주는 명령
핸재의 브랜치, 원격 브랜치, 추적중인 파일과 변경된 파일에 대한 정보를 알려줌
KST02@KST02 MINGW64 ~
$ mkdir git_status
KST02@KST02 MINGW64 ~
$ cd git_status/
KST02@KST02 MINGW64 ~/git_status
$ git init
Initialized empty Git repository in C:/Users/KST02/git_status/.git/
KST02@KST02 MINGW64 ~/git_status (master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
KST02@KST02 MINGW64 ~/git_status (master)
$ echo "<html></html>" > index.html
KST02@KST02 MINGW64 ~/git_status (master)
$ cat index.html
<html></html>
KST02@KST02 MINGW64 ~/git_status (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_status (master)
$ git add index.html
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
KST02@KST02 MINGW64 ~/git_status (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
KST02@KST02 MINGW64 ~/git_status (master)
$ echo "<html><h1>about</h1></html>" > about.html
KST02@KST02 MINGW64 ~/git_status (master)
$ ls -al
total 22
drwxr-xr-x 1 KST02 197121 0 10월 12 09:40 ./
drwxr-xr-x 1 KST02 197121 0 10월 12 09:21 ../
drwxr-xr-x 1 KST02 197121 0 10월 12 09:39 .git/
-rw-r--r-- 1 KST02 197121 28 10월 12 09:40 about.html
-rw-r--r-- 1 KST02 197121 14 10월 12 09:22 index.html
KST02@KST02 MINGW64 ~/git_status (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
-----------------------------------
add
Working Directory의 파일을 Staging Area로 옮기는 명령
git add <파일명> //명시된 파일을 Staging Area로 옮기기
git add index.html
git add . //추가 파일이 많은 경우에는 현재 디렉토리에 있는 모든 파일을 추가
git add -i // 인터렉티브한 방법을 이용해서 파일들을 추가
하나의 커밋에 여러 파일을 올리는 것은 나쁜습관이기떄문에
$ cd
KST02@KST02 MINGW64 ~
$ mkdir git_add
KST02@KST02 MINGW64 ~
$ cd git_add
KST02@KST02 MINGW64 ~/git_add
$ git init
Initialized empty Git repository in C:/Users/KST02/git_add/.git/
KST02@KST02 MINGW64 ~/git_add (master)
$ touch index.html
KST02@KST02 MINGW64 ~/git_add (master)
$ touch about.html
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
index.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_add (master)
$ git add index.html
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
KST02@KST02 MINGW64 ~/git_add (master)
$ git rm -cached index.html
error: did you mean `--cached` (with two dashes ?)
KST02@KST02 MINGW64 ~/git_add (master)
$ gir rm -caced index.html
bash: gir: command not found
KST02@KST02 MINGW64 ~/git_add (master)
$ git rm -caced index.html
error: unknown switch `c'
usage: git rm [<options>] [--] <file>...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
KST02@KST02 MINGW64 ~/git_add (master)
$ git rm --cached index.html
rm 'index.html'
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
index.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_add (master)
$ git add .
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: about.html
new file: index.html
KST02@KST02 MINGW64 ~/git_add (master)
$ git rm -r --cached
usage: git rm [<options>] [--] <file>...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
KST02@KST02 MINGW64 ~/git_add (master)
$ git rm -r --cached .
rm 'about.html'
rm 'index.html'
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
index.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_add (master)
$ git add -i
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now> 4
1: about.html
2: index.html
Add untracked>> 1
* 1: about.html
2: index.html
Add untracked>>
added 1 path
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now> q
Bye.
KST02@KST02 MINGW64 ~/git_add (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: about.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
-----------------
commit
Staging 영역에 있는 파일을 Repository에 저장
git commit // 에디터가 출력되어 에디터에서 메세지를 입력한 후 저장하면 커밋
git commit - m [커밋 메시지] // 간단하게 메시지를 입력하는 경우 사용 (50자 이내)
git commit -a -m [커밋 메시지] // add라는 명령어를 거치치 않고 repository에 가는 이미 commit한 파일을 수정해야하는 경우
KST02@KST02 MINGW64 ~/git_commit
$ git init
Initialized empty Git repository in C:/Users/KST02/git_commit/.git/
KST02@KST02 MINGW64 ~/git_commit (master)
$ touch index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_commit (master)
$ git add index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git commit
[master (root-commit) 0697383] Add index.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ touch about.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ ls
about.html index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ status
bash: status: command not found
KST02@KST02 MINGW64 ~/git_commit (master)
$ status
bash: status: command not found
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
about.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_commit (master)
$ git add about.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: about.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git commit -m "Add about.html"
[master 16e2b46] Add about.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 about.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ touch profile.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ gis status
bash: gis: command not found
KST02@KST02 MINGW64 ~/git_commit (master)
$ git statys
git: 'statys' is not a git command. See 'git --help'.
The most similar command is
status
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
profile.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_commit (master)
$ git commit -a -m "Add profile.html"
On branch master
Untracked files:
profile.html
nothing added to commit but untracked files present
KST02@KST02 MINGW64 ~/git_commit (master)
$ ls -al
total 20
drwxr-xr-x 1 KST02 197121 0 10월 12 14:25 ./
drwxr-xr-x 1 KST02 197121 0 10월 12 14:22 ../
drwxr-xr-x 1 KST02 197121 0 10월 12 14:26 .git/
-rw-r--r-- 1 KST02 197121 0 10월 12 14:23 about.html
-rw-r--r-- 1 KST02 197121 0 10월 12 14:20 index.html
-rw-r--r-- 1 KST02 197121 0 10월 12 14:25 profile.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ echo "<html></html>" index.html
<html></html> index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ cat index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ echo "<html></html>" < index.html
<html></html>
KST02@KST02 MINGW64 ~/git_commit (master)
$ cat index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ echo "<html></html>" > index.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ cat index.html
<html></html>
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
profile.html
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_commit (master)
$ git commit -a -m "Add html tag"
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
[master e21d455] Add html tag
1 file changed, 1 insertion(+)
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
profile.html
nothing added to commit but untracked files present (use "git add" to track)
KST02@KST02 MINGW64 ~/git_commit (master)
$ git add profile.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git commit profile.html
[master 8fe4e7d] "Add Profile"
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 profile.html
KST02@KST02 MINGW64 ~/git_commit (master)
$ git status
On branch master
nothing to commit, working tree clean
KST02@KST02 MINGW64 ~/git_commit (master)
$
log
저장소에 있는 commit 이력을 조회하는 명령
git log
커밋 이력 상세 조회
git log --oneline
커밋 이력중 커밋 ID,타이틀 메시지만 조회
git log --oneline --decorate -- graph --all
코든 브랜치 커밋 이력 조회
git log --index.html
특정 파일의 변경 커밋 조회
KST02@KST02 MINGW64 ~/git_commit (master)
$ mkdir git_log
KST02@KST02 MINGW64 ~/git_commit (master)
$ cd git_log/
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git init
Initialized empty Git repository in C:/Users/KST02/git_commit/git_log/.git/
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ touch index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git add index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commig -m "Add index.html"
git: 'commig' is not a git command. See 'git --help'.
The most similar command is
commit
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ touch about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit -m "Add about.html"
[master (root-commit) e997549] Add about.html
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 about.html
create mode 100644 index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ touch profile.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git add profile.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit -m "Add profile.html"
[master 92d0faa] Add profile.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 profile.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ echo "<html></html>" > index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit -a -m "Add html tag"
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
[master e513125] Add html tag
1 file changed, 1 insertion(+)
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log
commit e5131255177503b982b69fe743ec847eeec8bd39 (HEAD -> master)
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:48:17 2017 +0900
Add html tag
commit 92d0faa8b30b3d8d5c2f91df551603345472926b
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:47:27 2017 +0900
Add profile.html
commit e997549e777ce08f9d282b8d8ca5cffbaf037d68
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:46:43 2017 +0900
Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ echo "<html></html>" > about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit
On branch master
Changes not staged for commit:
modified: about.html
no changes added to commit
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit -a
warning: LF will be replaced by CRLF in about.html.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git commit -a
warning: LF will be replaced by CRLF in about.html.
The file will have its original line endings in your working directory.
[master 25d09e8] Modify about.html
1 file changed, 1 insertion(+)
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log
commit 25d09e898a70b1413f94027c233f4af4c1e617c8 (HEAD -> master)
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 15:01:59 2017 +0900
Modify about.html
-a\Add html tag
commit e5131255177503b982b69fe743ec847eeec8bd39
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:48:17 2017 +0900
Add html tag
commit 92d0faa8b30b3d8d5c2f91df551603345472926b
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:47:27 2017 +0900
Add profile.html
commit e997549e777ce08f9d282b8d8ca5cffbaf037d68
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:46:43 2017 +0900
Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --oneline
25d09e8 (HEAD -> master) Modify about.html
e513125 Add html tag
92d0faa Add profile.html
e997549 Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --oneline --decorate --graph --all
* 25d09e8 (HEAD -> master) Modify about.html
* e513125 Add html tag
* 92d0faa Add profile.html
* e997549 Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --index.html
fatal: unrecognized argument: --index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log -- index.html
commit e5131255177503b982b69fe743ec847eeec8bd39
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:48:17 2017 +0900
Add html tag
commit e997549e777ce08f9d282b8d8ca5cffbaf037d68
Author: mia <miamhchoi@gmail.com>
Date: Thu Oct 12 14:46:43 2017 +0900
Add about.html
좋은 커밋 메세지란?
커밋 메시지는 간단,명확하게
타이틀 : 변경에 대한 짧은 요약(50자이내) : oneline줄바꿈이 일어나지 않는 길이
필요한 경우 상세 설명 추가 ( 한줄에 72자 이내 )
추가적인 문단은 '-'를 이용하여 작성
-1번 작업 내용
- 2번 작업 내용
--------------------------------
diff
다른 커밋과 Working 디렉토리를 비교하는 명령
git diff
현재 브랜치의 마지막 커밋과의 차이점 비교
git diff [commit ID]
특정 커밋과의 차이점 비교
git diff [commit ID] --[파일 경로]
특정 커밋과 특정 파일의 차이점 비교
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git diff
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ cat pro
cat: pro: No such file or directory
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ cat profile.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ echo "<html>profile</html>" > profile.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: profile.html
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git diff
warning: LF will be replaced by CRLF in profile.html.
The file will have its original line endings in your working directory.
diff --git a/profile.html b/profile.html
index e69de29..675dbad 100644
--- a/profile.html
+++ b/profile.html
@@ -0,0 +1 @@
+<html>profile</html>
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --oneline
25d09e8 (HEAD -> master) Modify about.html
e513125 Add html tag
92d0faa Add profile.html
e997549 Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ vim index.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index.html
modified: profile.html
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --oneline
25d09e8 (HEAD -> master) Modify about.html
e513125 Add html tag
92d0faa Add profile.html
e997549 Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git diff ^C
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git diff e513125
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in profile.html.
The file will have its original line endings in your working directory.
diff --git a/about.html b/about.html
index e69de29..18ecdcb 100644
--- a/about.html
+++ b/about.html
@@ -0,0 +1 @@
+<html></html>
diff --git a/index.html b/index.html
index 18ecdcb..f7e187e 100644
--- a/index.html
+++ b/index.html
@@ -1 +1,4 @@
-<html></html>
+<html>
+ <head></head>
+
+</html>
diff --git a/profile.html b/profile.html
index e69de29..675dbad 100644
--- a/profile.html
+++ b/profile.html
@@ -0,0 +1 @@
+<html>profile</html>
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --online
fatal: unrecognized argument: --online
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --on3line
fatal: unrecognized argument: --on3line
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git log --oneline
25d09e8 (HEAD -> master) Modify about.html
e513125 Add html tag
92d0faa Add profile.html
e997549 Add about.html
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$ git diff e513125 -- index.html
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
diff --git a/index.html b/index.html
index 18ecdcb..f7e187e 100644
--- a/index.html
+++ b/index.html
@@ -1 +1,4 @@
-<html></html>
+<html>
+ <head></head>
+
+</html>
KST02@KST02 MINGW64 ~/git_commit/git_log (master)
$
merge
다른 두개의 소스를 병합하는 명령
git checkout master
git merge develop
KST02@KST02 MINGW64 ~
$ mkdir git_merge
KST02@KST02 MINGW64 ~
$ cd git_merge/
KST02@KST02 MINGW64 ~/git_merge
$ git init
Initialized empty Git repository in C:/Users/KST02/git_merge/.git/
KST02@KST02 MINGW64 ~/git_merge (master)
$ vim sum_of_1_to_100
KST02@KST02 MINGW64 ~/git_merge (master)
$ rm -rf sum_of_1_to_100
KST02@KST02 MINGW64 ~/git_merge (master)
$ vim sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (master)
$ cat sum_of_1_to_100.js
var sum = 0
for (i=1; i<100 ; i++){
sum += i;
}
console.log(sum)
KST02@KST02 MINGW64 ~/git_merge (master)
$ git add sum_of_1_to_100.js
warning: LF will be replaced by CRLF in sum_of_1_to_100.js.
The file will have its original line endings in your working directory.
KST02@KST02 MINGW64 ~/git_merge (master)
$ git commit -m "Add sum ot 1 to 100"
[master (root-commit) a9492af] Add sum ot 1 to 100
1 file changed, 6 insertions(+)
create mode 100644 sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (master)
$ git branch develop
KST02@KST02 MINGW64 ~/git_merge (master)
$ git checkuot develop
git: 'checkuot' is not a git command. See 'git --help'.
The most similar command is
checkout
KST02@KST02 MINGW64 ~/git_merge (master)
$ git checkout develop
Switched to branch 'develop'
KST02@KST02 MINGW64 ~/git_merge (develop)
$ vim sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (develop)
$ git status
On branch develop
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: sum_of_1_to_100.js
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_merge (develop)
$ git commit -a -m "Modify for statement"
warning: LF will be replaced by CRLF in sum_of_1_to_100.js.
The file will have its original line endings in your working directory.
[develop 863b36a] Modify for statement
1 file changed, 1 insertion(+), 1 deletion(-)
KST02@KST02 MINGW64 ~/git_merge (develop)
$ git ckechout master
git: 'ckechout' is not a git command. See 'git --help'.
The most similar command is
checkout
KST02@KST02 MINGW64 ~/git_merge (develop)
$ git checkout master
Switched to branch 'master'
KST02@KST02 MINGW64 ~/git_merge (master)
$ cat sum_of_1_to_100.js
var sum = 0
for (i=1; i<100 ; i++){
sum += i;
}
console.log(sum)
KST02@KST02 MINGW64 ~/git_merge (master)
$ vim sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (master)
$ git commit -a -m "fix beg"
[master 58f2bd2] fix beg
1 file changed, 1 insertion(+), 1 deletion(-)
KST02@KST02 MINGW64 ~/git_merge (master)
$ cat sum_of_1_to_100.js
var sum = 0
for (i=1; i<101 ; i++){
sum += i;
}
console.log(sum)
KST02@KST02 MINGW64 ~/git_merge (master)
$ git merge develop
Auto-merging sum_of_1_to_100.js
CONFLICT (content): Merge conflict in sum_of_1_to_100.js
Automatic merge failed; fix conflicts and then commit the result.
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ cat status
cat: status: No such file or directory
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ git sta
git: 'sta' is not a git command. See 'git --help'.
The most similar commands are
status
stage
stash
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: sum_of_1_to_100.js
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ vim sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ cat sum_of_1_to_100.js
var sum = 0
<<<<<<< HEAD
for (i=1; i<101 ; i++){
=======
for (i=1; i<=100 ; i++){
>>>>>>> develop
sum += i;
}
console.log(sum)
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ vim sum_of_1_to_100.js
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ cat sum_of_1_to_100.js
var sum = 0
for (i=1; i<101 ; i++){
sum += i;
}
console.log(sum)
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: sum_of_1_to_100.js
no changes added to commit (use "git add" and/or "git commit -a")
KST02@KST02 MINGW64 ~/git_merge (master|MERGING)
$ git commit -a -m "Merge Develop"
[master b9a8e47] Merge Develop
KST02@KST02 MINGW64 ~/git_merge (master)
$ git status
On branch master
nothing to commit, working tree clean
KST02@KST02 MINGW64 ~/git_merge (master)
$ git log --decorate --graph
* commit b9a8e47d0537426c232b99aed5afa39cb48652d4 (HEAD -> master)
|\ Merge: 58f2bd2 863b36a
| | Author: mia <miamhchoi@gmail.com>
| | Date: Fri Oct 13 10:48:05 2017 +0900
| |
| | Merge Develop
| |
| * commit 863b36a01a8b35937a69b3fb765b3e79fa218a40 (develop)
| | Author: mia <miamhchoi@gmail.com>
| | Date: Fri Oct 13 10:43:43 2017 +0900
| |
| | Modify for statement
| |
* | commit 58f2bd2e0e4f3a5d5782e1d4d12994b60317dd34
|/ Author: mia <miamhchoi@gmail.com>
| Date: Fri Oct 13 10:45:07 2017 +0900
|
| fix beg
|
* commit a9492af8d0c34eaa9269a1cb3ef43d273427521b
Author: mia <miamhchoi@gmail.com>
Date: Fri Oct 13 10:42:06 2017 +0900
Add sum ot 1 to 100
'버전관리' 카테고리의 다른 글
github를 이용한 소셜 코딩 (0) | 2017.10.13 |
---|---|
[생활코딩 4] SourceTree 버전만들기 Commit (0) | 2016.05.11 |
[생활코딩 3] SourceTree 저장소만들기 (0) | 2016.05.11 |
[생활코딩 2] Git과 SourceTree 설치 (0) | 2016.05.11 |
[프로젝트관리 1] 버전관리란? (0) | 2016.05.11 |