Dev/git

[git] git init --bare

냐옴 2022. 2. 17. 17:47

 

git remote repository 를 생성한다

$ git init --bare

 

로컬 PC 에서

  • 'git init --bare' 로 git 저장소를 만들고 'git push' 테스트 하기
##-----------------------------
## 폴더 생성
## - remote: git repository
## - local1: 로컬 작업영역 1
## - local2: 로컬 작업영역 2
##-----------------------------
WORK_DIR=./
mkdir $WORK_DIR/remote
mkdir $WORK_DIR/local1
mkdir $WORK_DIR/local2


##-----------------------------
## Remote
## - git remote repository 를 생성한다
##-----------------------------
cd $WORK_DIR/remote
mkdir proj1
cd proj1
git init --bare


##-----------------------------
## Local1
## - git init 으로 프로젝트를 초기화하고
## - 파일을 생성 후 커밋하고
## - git repository 에 push 한다
##-----------------------------
cd $WORK_DIR/local1
mkdir proj1
cd proj1
git init

touch git_example_project.txt
git add .
git commit -m 'initial commit'

git remote add origin $WORK_DIR/remote/proj1
git remote -v

git push -u origin master


##-----------------------------
## Local2
## - git clone 으로 프로젝트가 받아지는지 확인
##-----------------------------
cd $WORK_DIR/local2
git clone $WORK_DIR/remote/proj1