Skip to main content
Git Basic
5 / 8 (화)
멋쟁이 사자처럼 at 이화여대
Tutor . 김민정
Part 1 . VCS
버전 관리 시스템
Version Control System
기능 개선, 버그 수정, SW 커스터마이징
기능 개선, 버그 수정, SW 커스터마이징
의미 있는 변화 저장
1. 프로젝트의 변경 관리 : 코드 관리
2. 프로젝트의 버전 관리 : 되돌아가기
앗?! 이 버전으로 다시 돌아가서 작업할래!
3. 프로젝트의 협업 : 팀 프로젝트
민정
서영
준선
소스 코드의 변화를 관리
Version control system
근데 아기사자들이 가입한 사이트는?
튜터들이 달라고 찡찡거린 사이트는?!
소스 코드의 변화를 웹에서도 관리
Hosting service for git repositories
버전관리 tool Git을 사용하는 project를 위한 Service
Git 명령어를 이용해서 코드들의 버전들을 관리하고!
이런 버전들의 모음을 github에 올려서 공유한다.
간단한 사용법을 알아보자!
https://github.com/
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
repository C9의 workspace
1. 저장소 만들기 (repository)
repository Project의 directory
1. 저장소 만들기 (repository)
즉! 하나의 프로젝트 안에 들어가는
소스코드들의 최상위 폴더!
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
1. 저장소 만들기 (repository)
나의 프로젝트 (c9에 있는 소스파일들)
Github의 repository에 올리는 방법!
bash에 입력!
1. 저장소 만들기 (repository)
1:N or CRUD 프로젝트를
Github에 올려보자!
CRUD 프로젝트를
Github에 올려보자!
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
주소는 여기서 복사!
자신의 github 이메일 password 입력하기!
1:n 에서 튜터가 만들어둔 project를
복사해서 수정했던 것처럼!
이제 내 project의 진행사항을 web (github) 에
저장했으니 코드가 날라가도 괜찮아!
근데 이게 무슨 명령어지?
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
2. 깃 저장소 초기화 (init)
$ git init
# Starting a working area
# 현재 작업장에 작업을 진행하겠다는 것을 git에게 알려줘!
# 이 명령어 입력 전까지는 일반 폴더! git과 관계가 없다.
# git init 이후에야 추가적인 깃 명령어들을 줄 수 있다.
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
3. Commit 대기 (add)
$ git add .
# commit의 대기상태
# 내가 commit하고 싶은, 버전에 반영하고 싶은 파일만! Add
# commit 전에 add가 우선!
# add index.html.erb => 이 파일만 commit 대기
# add . => 모든 파일 commit 대기
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
4. 버전 만들기 (commit)
$ git commit –m ‘first commit’
# add 파일 (변경 내용)을 first commit이란 버전이름 설정
# commit하면서 기억하고 싶은 message를 함께 적자!
# 스냅 샷!
$ git commit –m ‘내용’
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
5. 업로드할 github 주소! (remote)
$ git remote add origin 주소
# 현재 작업하는 workspace를 연결한다!
# 나의 github repository에!
# 그 github repository에 origin이란 별명을 부여!
내 workspace와 주로 동기화하는 메인 repository를
관습적으로 origin이라고 부른다
git init
git add .
git commit –m “first commit”
git remote add origin 주소
git push –u origin master
6. Github에 올리기! (push)
$ git push –u origin master
# 내가 아까 remote한 repository는 origin!
# 이 origin을 push!
# 즉 나의 repository의 내용을 업로드 하겠다!
2. 깃 저장소 초기화 (add)
$ git add .
# commit의 대기상태
# 내가 commit하고 싶은, 버전에 반영하고 싶은 파일만! Add
# commit 전에 add가 우선!
# add index.html.erb => 이 파일만 commit 대기
# add . => 모든 파일 commit 대기
무슨 소리지 …
Code chage
Index.html
Code chage
git add
Index.html
git commit
$git add index.html
Code chage
git add histroy (git commit)
“index 수정!”
git commit –m “index 수정!”
Code chage
“create.html.erb”
“home_controller.rb”
git add histroy (git commit)
“index 수정!”
Code chage
git add
“create.html.erb”
“home_controller.rb”
histroy (git commit)
“index 수정!”
$git add .
Code chage
git add histroy (git commit)
“CRUD의 C완료!”
“index 수정!”
git commit –m “CRUD의 C완료!”
그러면 한번에 commit하면
되는거아냐?? add를 왜 해?
한 파일에 1commit
내가 add한 파일들에 1commit
git add
버전에 포함시킬 파일과 포함시키지 않을
파일을 구분짓기 위해서!
Code chage
index.html.erb
edit.html.erb
home_controller.rb
comment_controller.rb
git add histroy (git commit)
“CRUD의 C완료!”
“index 수정!”
Code chage
comment_controller.rb
git add
index.html.erb
edit.html.erb
home_controller.rb
histroy (git commit)
“CRUD의 C완료!”
“index 수정!”
$git add index.html.rb edit.html.erb home_controller.rb
Code chage
comment_controller.rb
git add histroy (git commit)
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
Code chage
comment_controller.rb
git add histroy (git commit)
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
Code chage
git add
comment_controller.rb
histroy (git commit)
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
$git add comment_controller.rb
Code chage
git add histroy (git commit)
“1:n 완료!”
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
git commit –m “1:n 완료!”
큰 작업에 따라 내가 add시키는
파일에 따라서 버전을 분리!
remote, push
내가 commit한 내용을
github에도 올릴래!
histroy (git commit)
“1:n 완료!”
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
Repository
- Html
- Rails
- Bootstrap
- Board
$ git remote add origin board
이 내용을 담을 repository는 Board야!!
이 board의 별명을 origin이라고 해줘!
histroy (git commit)
“1:n 완료!”
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
Repository
- Html
- Rails
- Bootstrap
- Board : origin
$ git push –u origin master
나의 commit내용을 repository에 업로드!
Board
“1:n 완료!”
“CRUD 완료!”
“CRUD의 C완료!”
“index 수정!”
2. 깃 저장소 초기화 (init)
$ git init
# Starting a working area
# 현재 작업장에 작업을 진행하겠다는 것을 git에게 알려줘!
# 이 명령어 입력 전까지는 일반 폴더! git과 관계가 없다.
# git init 이후에야 추가적인 깃 명령어들을 줄 수 있다.
3. Commit 대기 (add)
$ git add .
# commit의 대기상태
# 내가 commit하고 싶은, 버전에 반영하고 싶은 파일만! Add
# commit 전에 add가 우선!
# add index.html.erb => 이 파일만 commit 대기
# add . => 모든 파일 commit 대기
4. 버전 만들기 (commit)
$ git commit –m ‘first commit’
# add 파일 (변경 내용)을 first commit이란 버전이름 설정
# commit하면서 기억하고 싶은 message를 함께 적자!
# 스냅 샷!
$ git commit –m ‘내용’
5. 업로드할 github 주소! (remote)
$ git remote add origin 주소
# 현재 작업하는 workspace를 연결한다!
# 나의 github repository에!
# 그 github repository에 origin이란 별명을 부여!
내 workspace와 주로 동기화하는 메인 repository를
관습적으로 origin이라고 부른다
6. Github에 올리기! (push)
$ git push –u origin master
# 내가 아까 remote한 repository는 origin!
# 이 origin을 push!
# 즉 나의 repository의 내용을 업로드 하겠다!
[실 습]
새로운 workspace와
Repository 만들자!
1. 파일 지우기
2. index.html 파일 만들기
3. $git
4. $git init
5. $git add index.html
6. $git commit –m “index.html 파일 생성”
7. $git log : 나의 commit내역 살펴보기!
8. $git remote add origin 주소
9. $push –u origin master
10. index.html 수정
11. Git commit
12. Readme md 추가
13. Git commit
14. Git push
$Git : 깃 명령어 도움말
$git log : 나의 commit내역 살펴보기
$q로 나가요!
$git log -p : commit사이 달라진 내용!
$git log -2 : 최근 2개의 commit만
$git log를 보기 위한 좀더 편한 방법!
https://git-scm.com/book/en/v2/GitBasics-Viewing-the-Commit-History
Github에서 확인하기!
Github에서 확인하기!
이 commit에서의 repository 목록 보기
이 commit에서 달라진 점 (git log)
https://git-scm.com/doc
수고하셨습니다