버전 관리 시스템(형상관리)
ㄴ 버전관리를 하는 이유는 소스 데이터(.py 파일등)와 히스토리를 관리, 협업, 작업추적, 복구등이 가능
이전에는 소스 폴더+실행파일을 버전별로 카피하여 관리->컴퓨터가 다운되면 파일이 같이 날아가버림
파일 버전을 관리하기위해 Local Version Control Systems가 등장하며 내 컴퓨터에서 버전 관리가 가능해졌지만 컴퓨터가 하드가 날아가면 전체 코드가 사라짐. 버전은 관리되지만 여전히 협업에는 어려움
중앙에서 관리하는 Centralized Version Ccontrol Systems가 등장-> 협업이 가능하지만, commit하는 순간 배포되어 다수에게 버그 유발 가능, 인터넷이 안되면 작업 불가능, 자신만의 버전 히스토리가 없음
Distribured Version Control Systems가 등장. commit하더라도 개인 저장소 내에 적용(다른 개발자에게 영향없음), 언하는 순간에 배포(Push)가능, 오프라인테서도 작업 가능, 자신만의 버전 히스토리 가짐
CVCS- CVS, SVN, etc.
DVCS- Mercurial, Git, etc.
% git config --global core.autocrlf true
git config --global core.editor editor_name
전체 설정 확인
git config --list
항목별 설정 확인
git config key
git config user.name
Git이 관리하는 3가지 단계로 구성
Workspace 생성
mkdir git_ws
cd git_ws
git_ws/ mkdir test_project
git init
test_project/ touch test.txt
test_project/ ls
test.txt
git status
git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test.txt
git add filename
git commit -m "commit에 대한 설명" filename
git commit -m "first commit" test.txt
[master (root-commit) 36195e9] first commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
Github에서 Create Repository 생성
Github Token 생성
Remote Repository 접속 시 비밀번호 대신 Token 사용
Token 이름 입력 → No expiratio→ repo →Generate token 선택
Local Repository에 연동할 Remote Repository등록(Token사용)
Local Repository에 Remote Repository 등록
git remote add origin http://github.com/<repository>.git
Remote Repository 등록 with Username and Token
git remote add origin http://<username>:<token>@github.com/<repository>.git
$ git remote add origin https://swp0v0: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@github.com/swp0v0/test_project.git
git remote -v
Local Repository(HEAD)에 반영된 변경내용을 Remote Repository에도 반영하기 위해서는 Git Push를 사용
git push origin branchname
git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 206 bytes | 206.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/swp0v0/test_project.git
* [new branch] master -> master
⇊
Remote Repository페이지에 push된 파일 확인 가능
Remote Repository의 내용에 맞춰 Local Repository를 갱신하려면 Git Pull 사용
git pull origin branchname
git pull origin master
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 664 bytes | 55.00 KiB/s, done.
From https://github.com/swp0v0/test_project
* branch master -> FETCH_HEAD
36195e9..399d937 master -> origin/master
Updating 36195e9..399d937
Fast-forward
README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 README.md