반응형
A 컴퓨터를 main으로 잡고 B 컴퓨터에서 branch(development)를 설정해서 사용하기
1. 기본 셋팅하기
###### A 컴퓨터(main) ######
# linux
sudo apt update
sudo apt install git -y
# mac
brew install git
#####
git config --global user.name "githubusername" # github 닉네임을 적어야한다. github.com/여기오는이름/reponame
git config --global user.email "your-email@example.com"
# git 설정 확인
git config --global --list
# 저장소 초기화 (해당폴더안에서)
git init
# git 파일추가
git add .
# commit
git commit -m "내용"
# private 저장소연결
git remote add origin https://<username>:<personal-access-token>@github.com/<username>/<reponame>.git
# main push
git push -u origin main
##### B 컴퓨터 #####
# 클론
git clone https://<username>:<personal-access-token>@github.com/<username>/<reponame>.git
# 브랜치
git branch -r
git checkout -b <branch-name> origin/<branch-name> (이렇게해도 생성도 되는듯)
2. A컴퓨터에서 업데이트를 B컴퓨터에서 받기 (main -> branch)
##### A 컴퓨터 #####
# 변경 사항 추가
git add .
# 커밋
git commit -m "Update message"
# 원격 저장소로 푸시
git push origin main
#### B 컴퓨터 #####
# 호스팅 변경사항 가져오기
git fetch origin
git pull origin main
git checkout <branch>
git merge main
3. B컴퓨터의 업데이트를 A에서 받기 ( branch -> A)
# github에서 pull requests 진행
# base branch를 main으로, campare branch를 <branch>로 적용
# 리뷰어 지정, 메시지 추가 후 pr 생성
# pr 검토 및 승인
# merge pull request 진행
## Create a merge commit: 기본 병합 방식.
## Squash and merge: 커밋을 하나로 합쳐 병합.
## Rebase and merge: 브랜치 이력을 재배치하여 병합.
# 병합 완료 후 작업 브랜치 삭제 PR 화면에서 “Delete branch” 클릭. (해야하나?)
### github없이 진행 ####
# 1. main 브랜치로 이동
git checkout main
# 2. main 최신 상태 가져오기
git pull origin main
# 3. dev 브랜치 병합
git merge <branch>
# 4. 변경 사항 푸시
git push origin main
# 5. 병합 완료 후 브랜치 삭제
git branch -d <feature-branch>
git push origin --delete <feature-branch>
'Code' 카테고리의 다른 글
postgresql 서버에서 백업해서 로컬에 복원하기 (0) | 2024.12.16 |
---|---|
ios 시뮬레이터 업데이트 (0) | 2023.09.20 |