"Git"의 두 판 사이의 차이

오픈소스 비즈니스 컨설팅
둘러보기로 가기 검색하러 가기
잔글
잔글
122번째 줄: 122번째 줄:
 
"Windows -> Open Perspective" 메뉴에서 "Git"를 추가 합니다. "Clone a Git repository" 링크를 선택하여 리모트 Git repository를 등록 합니다.
 
"Windows -> Open Perspective" 메뉴에서 "Git"를 추가 합니다. "Clone a Git repository" 링크를 선택하여 리모트 Git repository를 등록 합니다.
  
[[File:Eclipse git 001.png|File:Eclipse git 001.png]] [[File:Eclipse git 002.png|File:Eclipse git 002.png]] [[File:Eclipse git 003.png|File:Eclipse git 003.png]]
+
[[File:Eclipse git 001.png|File:Eclipse git 001.png]]  
 +
 
 +
[[File:Eclipse git 002.png|File:Eclipse git 002.png]]  
 +
 
 +
[[File:Eclipse git 003.png|File:Eclipse git 003.png]]
  
 
== Git 명령어 ==
 
== Git 명령어 ==

2014년 10월 5일 (일) 11:32 판

오픈소스 분산 버전 컨트롤 시스템인 git를 정리 한다.


Git 개요

Git은 로컬 저장소를 가지며 SnapShot 형태로 버전을 관리 합니다.


Git 저장소

  • Work Space : 개인별 작업 공간
  • Staging Area (index) : Commit할 파일을 지정 (git add)
  • 로컬 저장소 : 자신이 작업한 내용을 반영 (git commit, git commit -a)
    • nonbare-repository : 프로젝트 리소스 저장
  • 원격 저장소 : 다른 사람과 작업을 공유할 때 사용 (git push / git pull (git fetch, git merge))
    • bare-repository : 이력, 변경 사항 저장
  • Work Space -> Staging Area (index) -> Local Storage -> Remote Storage


Master and Branch

  • Master : 로컬 저장소의 메인 코드 (git checkout master, git merge branch)
  • Origian : 초기 리모트 저장소
  • Branch : 새로 작업을 위해 생성한 코드 (git branch, git checkout, git checkbout -b)

Git 설치

CentOS에서 git 설치

Git 설치

yum install git
git version


Git 리모트 저장소 생성

groupadd git
useradd  -d /cloudnas/home/git -m -g git git
passwd git

su - git
git clone --bare zztemp.git
#--- /cloudnas/home/git/zztemp.git/ 폴더가 생성됨

git config --global user.name "Mountain Lover"
git config --global user.email "consult@jopenbusiness.com"
git config --list

Windows에서 git 설치

Git 설치

Git 다운로드 사이트에서 Windows용 Git 설치 파일(Git-1.9.4-preview20140815.exe)을 다운로드하여 설치 합니다.

P:/001_work/gitRepositor/ 폴더를 만들고 해당 폴더에서 오른쪽 마우스를 클릭 합니다.

File:Git install 001.png


Git Bash에서 Git 로컬 저장소 생성

git config --global user.name "Mountain Lover"
git config --global user.email "consult@jopenbusiness.com"
git config --global push.default simpe            #--- 현재 작업중인 branch만 push
git config --list

cd p:/001_work/gitRepository
git clone ssh://git@www.jopenbusiness.com/cloudnas/home/git/zztemp.git
#--- p:/001_work/gitRepository/zztemp/.git/ 폴더가 생성됨


Git 테스트

cd p:/001_work/gitRepository/zztemp
#--- aaa.xml 파일을 생성 합니다.
git status                              #--- 상태 정보 조회

git add aaa.xml                        
git status
git commit
git status
git push
git status


Git 설정 파일

  • /etc/gitconfig : git config -system (시스템별 설정)
  • ~/.gitconfig : git config --global (사용자별 설정)
    • c:/Users/ghkim/.gitconfig  for Windows
  • .git/config : git config (저장소별 설정)


참고 문헌


Eclipse에 GitHub 설치

Eclipse에서 GitHub를 사용하기 위해 GitHub를 설치 합니다.
"Help -> Install New Software... -> Add.." 메뉴에서 아래 사항을 추가하여 설치 합니다.


Eclipse 환경 설정

"Windows -> Open Perspective" 메뉴에서 "Git"를 추가 합니다. "Clone a Git repository" 링크를 선택하여 리모트 Git repository를 등록 합니다.

File:Eclipse git 001.png

File:Eclipse git 002.png

File:Eclipse git 003.png

Git 명령어

  • 저장소 : Work Space -> Staging Area (index) -> Local Storage -> Remote Storage
  • 버전 : Master, Branch
분류 명령어 상세
초기 설정 git init 현재 폴더를 로컬 저장소 생성
git remote add <repository> 리모트 저장소 연결
Repository : user@password:/~/~
  • ssh://[user@]host.xz[:port]/path/to/repo.git/
  • git://host.xz[:port]/path/to/repo.git/
  • http[s]://host.xz[:port]/path/to/repo.git/
  • ftp[s]://host.xz[:port]/path/to/repo.git/
  • rsync://host.xz/path/to/repo.git/
  • /path/to/repo.git/
  • file:///path/to/repo.git/
git clone <repository> 로컬 저장소로 리모트 저장소 복제
저장하기 git add Staging Area로 추가
git reset HEAD Staging Area에 추가할 파일을 삭제
git commit 로컬 저장소로 commit
git commit -a git add + git commit
git fetch origin
git reset --hard origin/master
로컬 저장소로 commit한 것을 복구
git push 리모트 저장소로 commit
가져오기 git fetch 로컬 저장소로 가져오기
git merge 로컬 저장소의 소스와 병합
git pull git fetch + get merge
버전 관리 git branch ~ 브랜치 생성
git checkout ~
git checkout -b ~ git branch + git checkout
git branch -d ~ 브랜치 삭제
git checkout master
git merge branch 브랜치 병합
git branch
git branch --no-merged
git branch --merged
브랜치 목록
태그 관리 git tag ~
git tag -a ~
태그 생성
git tag -d ~ 태그 삭제
git tag 태그 목록
설정 관리 git config --list
git config <설정명>
설정 정보 조회
git config [--system | --global] <name> "<value>" 설정 등록

참고 문헌