학교

[GitHub] Repository 병합

daykim 2021. 8. 7. 17:52

1. 병합하기 위한 repository 만들기

2. git bash 켜기

3. 

git clone [병합하려는 repository 주소]

4. 해당 폴더로 이동

cd [repository 이름]

5. 병합하려는 repository의 파일들 fetch

mkdir [병합하려는 repository 이름]

git subtree add --prefix=[병합하려는 repo 이름]/[병합하려는 repo 이름] [병합하려는 repo 주소]
  • 만약 위에서 오류 발생시 다른 방식 사용
git remote add [remote 이름] [병합할 repository 주소]

git fetch [remote 이름]
# 위의 명령어 수행시 나옴 : * [new branch]      브랜치명       -> 레파지토리이름/브랜치명

git merge [위의 레포지토리이름/브랜치명]

# fatal: refusing to merge unrelated histories 에러 시
git merge --allow-unrelated-histories [위의 레포지토리이름/브랜치명]

6.  push 하기

git add .
git commit -m "message"
git push origin master

 

* 문제점 발생

- git bash에서 오랜시간 기다려도 push가 되지 않았다. 오류메시지도 따로 없었다.

- cmd 창을 켜서 push 시도를 하니 github에 권한 설정을 안 했다고 나왔다. 이를 해결하니 push 되었다.

 

참고한 URL

https://velog.io/@lina0322/git-git-repository-%ED%95%A9%EC%B9%98%EA%B8%B0git-log-%EC%A7%80%ED%82%A4%EA%B8%B0