
VCS : 소프트웨어의 파일(코드, 구조 등)에 가해진 변경을 추적하여 관리하는 소프트웨어.
SCM(Source Code Management System)이라고도 불린다.
다양한 종류의 VCS가 사용되고 있음.
역할 :
Repository : SW의 변경사항들을 기록해주는 Database중앙집중식 버전 관리 시스템 : 가장 일반적인 방법
분산형 버전 관리 시스템 :
git :
Linus Torvalds가 linux kernel을 개발하기 위해 만들어 졌다.
지금은 많은 SW 회사들이 사용하고 있다.
delta storage :
snapshot storage :
Three states
git repository (Commited) :working directory (Modified) :staging area (Staged) :Basic workflow
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
On Ubuntu : sudo apt-get install git
https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
Your Identity :
Your Editor : 주로 사용하는 editor 지정
Checking your settings :
A basic workflow :
Init a repository or Cloning an existing repositoryEdit files :
Stage the changes : Review your changes :
Commit the changes :
View history : 현재까지의 변경사항을 보여준다우리가 개발하는 SW에 main line이 있는데,
main line에서 벗어나 별도로 다른 방향으로 SW를 개발할 때, branching한다고 한다.
branching한 작업을 main line으로 합치는 과정을 merging이라고 한다.
➡️ non-linear하게 동시에 여러가지 일을 개발할 수 있기 때문에 사용함
시나리오 1
git commit -m "my first commit"
git commit
git commit
git checkout -b bug123 ➡️ 기존의 master에서 bug123으로 branch하겠다.
git branch ➡️ "master, bug123(*)" 출력
git commit
git commit
git checkout master ➡️ pointer를 master branch로 옮기기
git merge bug123 ➡️ 현재 branch와 bug123 branch를 merge하라.
git branch -d bug123 ➡️ bug123 branch를 없애라.

시나리오 2 :
master branch와 bug456 branch는 서로 다른 작업으로 진행되고 있다.
git checkout master
git merge bug456
만약 두 branch를 merge할 때,
master branch의 D, E 변경과 bug456의 F, G 변경이 disjoint하다면 문제 없이 merge된다.
예를 들어, mastser branch에서는 func1을 update했고, bug456은 func2를 update 하면? 문제 없음.
하지만 두 branch에서 동일한 함수에 대해서 변경이 있었다면, merge가 자동적으로 될 수 없다.
이렇게 conflict가 발생한다면, 우리는 conflict가 발생한 부분을 직접 고쳐야 한다.
그리고나서
git branch -d bug456
shared repository model(remote repo)이 있음.
각각의 개발자들은 그 remote repo을 checkout해서, 본인의 작업을 수행.
Github는 shared repository model(remote repo)를 만들 수 있게 하는 대표적인 서비스
clone하여 project 가져오기
git log
git log -p
git log --oneline
git log --oneline --graph
git log --stat
git checkout d379
"d379" 지점은 main 함수에서 goo()함수를 호출하기 직전 버전이다.
"d379" commit 시점 버전
git branch :
git branch myexp :
git checkout myexp :
개발하기 위해 기존 code들 변경.


git status :
git add :
git commit :
git checkout main; git merge(myexp) :

git branch -d myexp :
git branch -M <바꿀 branch명> :



git configuration

git init


git add .: stating area로 보내기



.gitignoregit add를 했는데 object file이나 library file들이 포함되어있다.git resotre --staged {파일명}
이럴 때는 git rm --cached {파일명}

.gitignore 파일에서 변경을 추적하지 않을 파일들을 명시해줄 수 있다
(after .gitignore)

object files나 library들이 추적되지 않는 것을 볼 수 있다.git commit -m "message"

git remote repository 생성 후, local repository를 remote repository에 연결
(아직 remote repository에 연결되어 있지 않다.)


git push -u {리모트이름} {localbranch이름}

(github repository 새로고침)
include/funcs.h 생성하고, initial commit하기.

Makefile 생성하고, commit하기
git restore --staged bin/myapp obj/*.o :


.gitignore file 생성 :

(bin/, obj/ file들이 생겼어도 staging되지 않은 것을 알 수 있다.)zoo() 함수 추가하기.
zoo() 함수 추가하기 전으로 branching해서, koo() 함수 만들고,master branch와 merging하기.


master branch와 kooexp branch merge하기.



conflict가 발생하여, 기존의 zoo() 함수 지우고, 새로 개발한 koo() 함수로 변경.

git remote add origin <생성된 github 원격 repository link> :

git branch -M main :



git pull main == git fetch origin; git merge origin/main :git pull main

git fetch origin; git merge origin.main



week09_git/생성,
add, sub, mul, div하는 프로그램 빌드 (make file 사용 X)
조건 1: build시, make file 이용 X
조건 2: myadd, mysub, mymul, mydiv에 대한 각각의 object file들을 공유 라이브러리 /lib/myops.so로 만들기
조건 3: myapp.c와 linking하여 최종 실행 파일로 빌드






현재까지 진행상황을 commit하고, remote repository에 push



새로운 advanced_dev branch 생성 후, commit
mypow mymod 개발하여 프로그램 빌드
조건 1: build시, make file 이용 X
조건 2: mymod, mypow에 대한 각각의 object file들을 공유 라이브러리 /lib/myops.so로 만들기
조건 3: myapp.c와 linking하여 최종 실행 파일로 빌드








main branch로 checkout 후, advanced branch와 merge
merge하지 않았으니 main branch는 아직 advanced branch에서의 변경사항이 적용되지 않음.


remote repository에 push
아래 사진에서 보이듯, 현재 local branch가 remote branch보다 1 commit 앞서있는 상황이므로 remote branch에 현재 변경 사항을 push해줘야 함.


위에서 최종적으로 빌드했던 bin/myapp을 makefile을 이용하여 빌드할 것임.
makefile 생성 후, push


remote repository에서 README.md 생성 또는 수정 후, local repository로 git pull (fetch + merge)


이제 remote repository에서 가한 변경을 local에 가져오기 pull(fetch + merge)
git pull origin main = git fetch origin; git merge origin/main


