728x90

GIT

 

깃마스터 - 버전관리

 

현업에서는 깃을 형상관리도구로 다씀

분산버전시스템 (repository)

원격저장소 : 깃허브

 

전세계의 소스코드는 깃허브 원격저장소에 저장되고 있음

 

commit으로 자기버전 쌓아두고 순서대로 push해야함

자신버전 관리 -> 원격으로 보내기

fetch -> pull

fetch : 변경사항의 이력을 알고싶을 때 

pull : 변경사항 반영

 

마스터의 줄기 -> branch의 확장

보통은 한명이 하나의 branch쓰고 나머지 합치기용 branch

head : 내가 최종버전을 가지고 있다. 마지막 업데이트한 사람의 정보가 들어가 있음. branch의 중심에 있다

로컬 2에서 pull을 받고 내 정보를 최신버전으로 업글하고 commit해야 reject안당함 => pull할때 데이터 잘날라가서

따로 파일에 저장해두고 그 소스코드를 올리자!

 

 

conflict이 발생하면 merge해야함

 

staging (commint하기 이전단계)

 

 

**Git

--cmd창에

cd 저장공간

git version

-> install well

 

 

 

Microsoft Windows [Version 10.0.18362.1016]

(c) 2019 Microsoft Corporation. All rights reserved.

 

C:\Users\kosta>git config --global user.name "moon"

 

C:\Users\kosta>git config --global user.email "mhee4321@hanmail.net"

 

C:\Users\kosta>git config --global color.ui true

 

C:\Users\kosta>mkdir hello

 

C:\Users\kosta>cd hello

 

C:\Users\kosta\hello>git init

Initialized empty Git repository in C:/Users/kosta/hello/.git/

 

C:\Users\kosta\hello>git status

On branch master

 

No commits yet

 

nothing to commit (create/copy files and use "git add" to track)

 

C:\Users\kosta\hello>git status

On branch master

 

No commits yet

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

 

        hello.html

 

nothing added to commit but untracked files present (use "git add" to track)

 

C:\Users\kosta\hello>git add hello.html

 

C:\Users\kosta\hello>git status

On branch master

 

No commits yet

 

Changes to be committed:

  (use "git rm --cached <file>..." to unstage)

 

        new file:   hello.html

 

 

C:\Users\kosta\hello>

 

C:\Users\kosta\hello>git commit -m "add hello.html" (""안에는 내가 쓰고싶은 메시지)

 

[master (root-commit) 3892bea] add hello.html

1 file changed, 8 insertions(+)

create mode 100644 hello.html

 

C:\Users\kosta\hello>git status

On branch master

nothing to commit, working tree clean

 

 

C:\Users\kosta\hello>git log

commit 3892beae05731b9dc96300b9d1f9eec017f0a3d3 (HEAD -> master) **head가 누군지 아는게 제일중요!

Author: moon <mhee4321@hanmail.net>

Date:   Thu Oct 8 10:24:17 2020 +0900

 

    add hello.html

 

 

**브랜치(branch)

C:\Users\kosta\hello>git branch

* master

 

C:\Users\kosta\hello>git branch -v

* master 5309927 add styling2   (앞에 * : head -> master로 잡혀있다)

 

 

처음 테스팅은 마스터와 같은 값을 가짐

head의 주인을 테스팅으로 바꿔보장!!

 

C:\Users\kosta\hello>git branch

* master

 

C:\Users\kosta\hello>git branch -v

* master 5309927 add styling2

 

C:\Users\kosta\hello>git branch testing

 

C:\Users\kosta\hello>git branch -v

* master  5309927 add styling2

  testing 5309927 add styling2

 

C:\Users\kosta\hello>git checkout testing

Switched to branch 'testing'

 

C:\Users\kosta\hello>git branch -v

  master  5309927 add styling2

* testing 5309927 add styling2

 

C:\Users\kosta\hello>git add test.js

 

 

C:\Users\kosta\hello>git commit -a -m "add test.js" (a : 스테이지와 커밋을 동시에 진행)

[testing e4c193d] add test.js

2 files changed, 3 insertions(+)

create mode 100644 test.js

 

C:\Users\kosta\hello>git branch -v

  master  5309927 add styling2

* testing e4c193d add test.js (테스팅의 주소가 바뀜)

 

C:\Users\kosta\hello>git checkout master

Switched to branch 'master' => 자동으로 코드가 없어지거나 생김

 

 

 

**merge

  1. fast-forward : 늦는 버전 아이가 head를 가지고 최신버전을 merge함

 

(마스터입장에서 testing을 merge함)

C:\Users\kosta\hello>git reset --hard 5309927

HEAD is now at 5309927 add styling2

 

C:\Users\kosta\hello>git add hello.html

 

C:\Users\kosta\hello>git commit -m "add 2version hello.html"

[master 12c114a] add 2version hello.html

1 file changed, 1 insertion(+)


마스터가 다른 독보적인 길로 들어갔을때(나뉜 브런치 합치기) -> 서로서로 merge함

(마스터입장에서 testing을 merge하고

testing입장에서 마스터를 merge해준다)

C:\Users\kosta\hello>git add hello.html

 

C:\Users\kosta\hello>git commit -m "add 3version hello.html"

[master 34facfa] add 3version hello.html

 

C:\Users\kosta\hello>git status

On branch master

nothing to commit, working tree clean

 

C:\Users\kosta\hello>git branch -v

* master  34facfa add 3version hello.html

  testing e4c193d add test.js

 

C:\Users\kosta\hello>git merge testing

Already up to date.

 

C:\Users\kosta\hello>git branch -v

* master  34facfa add 3version hello.html

  testing e4c193d add test.js

 

C:\Users\kosta\hello>git checkout testing

Switched to branch 'testing'

 

C:\Users\kosta\hello>git merge master

Updating e4c193d..34facfa

Fast-forward

hello.html | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

 

C:\Users\kosta\hello>git status

On branch testing

nothing to commit, working tree clean

 

C:\Users\kosta\hello>git branch -v

  master  34facfa add 3version hello.html

* testing 34facfa add 3version hello.html

  1. recursive(재귀) : 공통조상을 찾아서 처리

 

 

**Github(Eclipse와 Git연동)

 

  1. gitgub에서 repository생성 => 새로운 원격 저장소 생성

  2. local Repository생성 => 원격저장소 주소에 접속 (clone으로 사용)

  3. 새 프로젝트 생성

  4. 프로젝트와 로컬 레퍼지토리 연결 (프로젝트 우클릭 team -> share teamproject), GIT staging키기(window->show view -> other

  5. git -> 프로젝트 우클릭 ->push branch master(branch 1개일때)

  6. 만든내용 commit, push


  1. 상대컴퓨터가 초대에 응하고 import해서 프로젝트 불러오고(에러잡기 위한 src폴더 생성) 

  2. commit, push

  3. new branch 생성(testing) master이외로 만듦

 

77(원격 repository생성 -> 로컬 repository생성 -> 자신의 프로젝트 생성->commit, push -> 로컬, 원격repository로 복사됨

75(77의 원격repository를 import해서 가져옴 ->로컬 repository생성 -> +뉴소스 -> commit, push ->77의 원격 repository로 넘어감

77이 변한 소스코드를 프로젝트에 적용시키려면 pull을 가져와서 소스확인하면 끝!

내입장에서는 pull을 먼저받고 push을 줘야 함 merge

 

!만약 75가 다른 브런치 testing을 만들어서 프로젝트 push하면 77의 원격저장소는 master와 testing 두개의 공간이 생긴다.

-그렇다면 77은 testing에 있는 pull을 받아야 함. -> 프로젝트에 생성

-master원격저장소에도 push해줘야 원격저장소 두군데 + 프로젝트에 다 변경된 사항 저장됨

 

**충돌에러(공통된 파일을 서로고칠때 발생)

똑같은 html을 서로가 고쳐서 push로 보내는데 이미 다른사람이 push해서 새로운 버전이 나있는상태. 다른사람이 push하면 충돌이 뜨기 때문에 merge하고 push하라고 에러메시지가 뜸 그러면 merge하고 내가 원하는 순서 정해서 저장하고 push하기 

 

-->**팀프로젝트

  1. 그렇기 때문에 충돌에러가 뜨지 않기 위해서 공통파일을 최소화하기(board.xml, controller 각자 하나씩 만들기)

  1. 오전 오후단위로 백업(pull받았을 때 예상치못한 오류가 나올 수 있어서 내 자료는 백업해두기)

  2. push는 정해진 시간안에서 하는 것-> 규칙세우기 5시에 push하기

 

 

 

 

 

 

 

728x90

'PROJECT' 카테고리의 다른 글

GIT 사용법 (2) + 개인블로그 관리  (0) 2021.01.16
SCRUM 회의  (0) 2020.11.13

+ Recent posts