상세 컨텐츠

본문 제목

[git] intellij 프로젝트 git 올리기

ETC

by jeonghojin 2023. 2. 6. 11:06

본문

프로젝트를 진행하던 중 bitbucket에 프로젝트를 올릴 경우, 에러가 발생했다.

* bitbucket 에 프로젝트 생성후, repository를 생성하고 프로젝트를 올리려 했지만 에러 발생

 

 

 

intellij 에서 시도해보았지만, 실패해서 bash에서 명령어로 시도.

 

git init
git add --all
git commit -m "{commit message}"

 

파일 추가

git remote add origin https://{유저명}@bitbucket.org/{유저명}/{repository 명}.git
git push -u origin master

 

! [reject] ~~~ 발생

 

*github에서 레파지토리를 생성할 때, README.md, gitignore 파일을 생성했기 떄문이라고 한다.

 


해결방법 : 

1. master 를 pull하여 원격 repository를 local 로 fetch하여 merge

git pull origin master

 

 

첫번째 방법으로 실패할 경우, 아래와 같은 에러 메시지 출력

fatal: refusing to merge unrelated histories

* commit 히스토리가 서로 연관성이 없어 merge가 거절

 

git pull origin master --allow-unrelated-histories
git status

 

status 확인 후, 다시 진행해준다.

git remote add origin https://{유저명}@bitbucket.org/{유저명}/{repository 명}.git

관련글 더보기