13 Git 사용법
13.Git 사용법
들어가기 전에...
- 이 글은 kkamagui에 의해 작성된 글입니다.
- 마음껏 인용하시거나 사용하셔도 됩니다. 단 출처(http://kkamagui.tistory.com, http://kkamagui.springnote.com)는 밝혀 주십시오.
- 기타 사항은 mint64os at gmail.com 이나 http://kkamagui.tistory.com으로 보내주시면 반영하겠습니다.
- 상세한 내용은 책 "64비트 멀티코어 OS 원리와 구조"를 참고하기 바랍니다.
1.Git에 user.name과 user.email 설정
사용자가 kkamagui이고 email이 kkamagui@gmail.com이라면 아래와 같이 입력하면 된다.
- $>git config --global user.name "kkamagui"
- $>git config --global user.email "kkamagui@gmail.com"
2.Git에 설정된 global config 값들 표시
- $>git config --global --list
3.표시되는 메시지를 컬러로 보기
Git에서 표시되는 메시지는 기본적으로 단색이다. 그런데 이를 컬러로 보고 싶다면 아래와 같이 입력하면 된다.
- $>git config --global color.ui "auto"
4.문자셋 설정하기
Git에서 사용하는 문자셋은 기본적으로 UTF-8이다. 만약 UTF-8이 아닌 EUC-KR을 사용하고 싶다면 아래처럼 입력하면 된다.
- $>git config --global i18n.commitEncoding cp949
- $>git config --global i18n.logOutputencoding cp949
5.내장 도움말 보기
Git에서 내장된 도움말을 보고 싶다면 아래처럼 입력하면 된다.
- $>git help <command>
예를 들어 commit에 대한 도움말을 보고 싶다면 git help commit과 같이 입력하는 식이다.
6.Git Project 생성하기
testgit 디렉토리를 만들어서 Git으로 버전관리를 하고 싶다면 아래와 같이 입력하면 된다.
- $>mkdir testgit
- $>cd testgit
- $>git init
- Initialized empty Git repository in /home/kkamagui/project/testgit/.git/
7.저장소에 파일 추가하기
testgit에 a.txt 파일을 추가하고 싶다면 아래와 같이 입력하면 된다.
- $>git add a.txt
8.저장소의 상태 확인하기
- testgit 디렉토리의 상태를 알고 싶으면 아래와 같이 입력하면 된다.
$>git status - kkamagui@ubuntu:~/project/testgit$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: a.txt
#
9.변경사항 로컬 저장소에 저장하기
변경사항을 로컬 저장소(Local Repository)에 저장하고 싶다면 아래와 같이 입력한다.
- $>git commit -m "최초 추가"
[master (root-commit) 237a76b] 최초 추가
1 files changed, 3 insertions(+), 0 deletions(-)
create mode 100644 a.txt
10.변경 이력 보기
변경 이력(Commit Log)를 보고 싶다면 아래와 같이 입력한다.
- $>git log
- commit 237a76b9f3ccd65df523d6434d5ea4fa14142079
Author: kkamagui <kkamagui@gmail.com>
Date: Wed Nov 30 10:57:13 2011 +0900
최초 추가
변경 이력이 많을 경우 범위를 개수를 제한할수 있는데, -숫자를 입력하면 된다. 예를 들어 최근 변경 이력 하나만 보고 싶다면 아래와 같이 입력한다.
- $>git log -1
History
Last edited on 11/30/2011 11:13 by kkamagui
Comments (0)