한 프로젝트를 깃랩과 깃허브 두 곳에 push하고 싶어서 알아봤다.
현재 로컬 저장소인 Mini_WAS 폴더와 깃랩 원격 저장소와 연결되어있다.
이제 내 깃허브 원격 저장소와도 연결하고 싶어서 과정을 기록하려고 한다.
새로 연결하고 싶은 원격 저장소명과 URL
git remote add "저장소명" "url"
원격 저장소 목록 확인
git remote -v
origin(깃랩)으로 push와 저장소명(깃허브)으로 push
git push origin master
git push 저장소명 master
//ex) git push Mini_WAS master
origin(깃랩)으로 pull와 저장소명(깃허브)으로 pull
git pull origin master
git pull 저장소명 master
그런데!
! [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.
push 하려고 하니까 이런식으로 에러가 떴다.
git pull을 해줬는데도 안됐다. 그래서 구글링 해봤다.
원인
원인은 .gitignore 파일 또는 README.md 파일로 인해 발생한다고 한다.
해결 방법
master 앞에 +를 붙이기
git push origin +master
'IT > Git' 카테고리의 다른 글
[Git] git 연결 끊기 & 새로운 로컬 저장소 연결 (0) | 2020.12.14 |
---|---|
[Git]git branch 실습 (0) | 2020.11.16 |