<이전글>

2020/12/03 - [IT/Git] - [Git] Git 원격 저장소 여러개 연결

 

[Git] Git 원격 저장소 여러개 연결

한 프로젝트를 깃랩과 깃허브 두 곳에 push하고 싶어서 알아봤다. 현재 로컬 저장소인 Mini_WAS 폴더와 깃랩 원격 저장소와 연결되어있다. 이제 내 깃허브 원격 저장소와도 연결하고 싶어서 과정을

song-yujin.tistory.com

 

1. git 연결 끊기


git 연결 끊기
git remote remove origin

 

git init 취소
rm -r .git

 

 현재 연결되어있는 저장소 경로 보기
git remote -v

 

 

2. 새로운 로컬 저장소 연결

깃랩에 있는 Mini_WAS 저장소와 새롭게 연결하고 싶은 로컬 저장소를 연결하려고 한다.

 

새로 연결하고 싶은 원격 저장소명과 URL 
git remote add "저장소명" "url"

 

그런데!!

이전 글을 참고해서 git push origin master과 git push origin +master 둘 다 해봤는데 아래처럼 표시가 되었다.

$ git push origin master
To http://~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'http://gitlab-intern.polloud.com/songij4/mini_was.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

~~~~@~~~ MINGW64 ~/eclipse-workspace/Mini_WAS2 (master)
$ git push origin +master
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 4 threads
Compressing objects: 100% (77/77), done.
Writing objects: 100% (87/87), 38.01 KiB | 2.38 MiB/s, done.
Total 87 (delta 12), reused 0 (delta 0), pack-reused 0
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To http://gitlab-intern.polloud.com/songij4/mini_was.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://gitlab-intern.polloud.com/songij4/mini_was.git'

 

원인

 

깃랩은 저장소를 생성하면 기본설정이 '관리자(Maintainers)'만 수정 가능하다.

'개발자(Developers)'는 푸시 허용이 돼 있지 않아서 나는 오류이다.

 

 

해결 방법

 

깃랩 레파지토리에서 > settings > Repository > Protected Branches > 선택하는 부분에 Developers + Maintainers 해주면 된다. 

그리고 다시 git push origin +master 해주면 잘 된다!

'IT > Git' 카테고리의 다른 글

[Git] Git 원격 저장소 여러개 연결  (0) 2020.12.03
[Git]git branch 실습  (0) 2020.11.16

+ Recent posts