-
[git] branch 확인 및 가져오기, 생성 후 Remote Repository에 push하기git 2023. 1. 15. 22:43반응형728x90
1. Local에 있는 branch 확인하기
git branch -a
2. Remote Repository에 있는 branch 확인하기
git branch -r
3. Local에 새로운 branch 생성하기
git branch 브랜치명
4. Remote Repository에 브랜치 생성하기
: Local에 먼저 만든 후 작업해야한다.
아닐 경우 아래와 같은 에러를 마주친다.
error: src refspec feature/common does not match any
error: failed to push some refs to 'https://github.com/S2LC/lbss-back.git'git push origin 브랜치명
명령어를 치면 아래와 같이 원격저장소에 브랜치가 생성되었음을 알려준다.
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'develop' on GitHub by visiting: remote: https://github.com/S2LC/lbss-back/pull/new/develop remote: To https://github.com/S2LC/lbss-back.git * [new branch] develop -> develop
이후 develop으로 브랜치 변경 후 pull을 하면 아래와 같이 뜬다.
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> develop
이것은 로컬 브랜치가 어떤 원격 브랜치를 추적할 것인지에 대한 내용이다.
아래와 같은 명령어로 해결할 수 있다.
5. 추적할 원격 브랜치 설정
git branch --set-upstream-to=origin/원격브랜치명 로컬브랜치명
cf) 6. 브랜치 변경
git checkout 브랜치명
cf) 7. 원격 저장소(Remote Repository)에서 브랜치 가져오기
$ git checkout -t origin/브랜치명
728x90'git' 카테고리의 다른 글
[git] cherry-pick와 merge 및 rebase를 활용한 commit 내역 관리 (0) 2024.05.26 [gitlab, git] git mirror하기 (다른 repo 소스코드 gitlab에 옮기기) (0) 2023.06.12 [git] 원격저장소(Remote Repository)에 이미 push한 commit 삭제하기 (0) 2022.12.22