Infra & Tools/GIT

Git Hub 동시에 두개의 Repo 에 올리기!

sung.hyun.1204 2022. 8. 6. 11:21

 

 

 

원하는 상황은 다음 과 같다. 

 

 

 

1. 온라인 git.hub 에 두개의 repo 가 있다.

 

주황색 : team project repo   :Team/repo

파란색 : personal study repo: Personal/repo

 

2. local 나의 노트북 에도 위 각각을 클론 받은 repo 가 있다. 

 

3. 원하는 상황 ! ===> Folder1 에 작헙 하던것을 team repo에 올리면 자동으로  personal / repo1  에도 적용이 되는 것

point : 최대한 간단 하게 1줄 커맨드 커밋으로 올리는 것

 

방식 :

     $ git remote set-url origin --push --add  https://github.com/~ .git

 

 

---------------------------------------------------------------------------------------------------

 

Git hub repo 이름 권장 : 

 1. 소문자 2 . dash  3. 구체적 specific

 damn,,, repo에  이름 첫글자 대문자가 있다 

github settings에 들어가 repo rename 을 해주자. Java -> gitRepoJava 카멜 표기로 변경

 

Java 라고 해둔거

 

 

---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------

 

team project repo  에 들어가 현재 연결되 상황을 사펴본다 , 나의 팀 repo 주소는 다음과 같다.

 ~/Desktop/summerhackaton/Server >main

 

1. git 연결 확인   : $ git remote -v

 

결과:

origin https://github.com/HUFSummer-Hackathon/Server.git (fetch)
origin https://github.com/HUFSummer-Hackathon/Server.git (push)

 

fetch ? push?  두개 가 나온다 뭐지?

 

fetch :

push : 

 

 

2.  새로운 단축이름(originJava)으로 Git Repository 추가 (git remote add)

 

$ git remote add originJava https://github.com/chosunghyun18/gitRepoJava.git

 

$git remote -v

 

결과 

origin https://github.com/HUFSummer-Hackathon/Server.git (fetch)
origin https://github.com/HUFSummer-Hackathon/Server.git (push)
originJava https://github.com/chosunghyun18/gitRepoJava.git (fetch)
originJava https://github.com/chosunghyun18/gitRepoJava.git (push)

 

--> 두개의 repo 에 각각 올리는 방법으로 올려야 한다.

ex) 

$ git push origin master

$ git push originJava master

 

처음 고려한 상황과 맞지 않다.  ->>> 한개의 단축 이름으로 두개의 repo를 관리 해야함.

 

 

1. 방금 만든 originJava 삭제.

 

$ git remote remove  originJava 

 

!! 2. 설정 !!!

$ git remote set-url origin --push --add  https://github.com/chosunghyun18/gitRepoJava.git 

 

$ git remote -v

 

결과: 

origin https://github.com/HUFSummer-Hackathon/Server.git (fetch)
origin https://github.com/chosunghyun18/gitRepoJava.git (push)

 

설정 돌리기

$ git remote set-url origin --push --delete https://github.com/chosunghyun18/gitRepoJava.git

---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------

 

 

 

위가 끝이 면 좋지만 문제 점이 있다.

 

각각 .git 이 있는 폴더 위치에  공유하고 싶은 폴더 이름이 각각 다르다.

 

Team-repo 는 Server 라는 폴더에 코드가 있고

Local -repo 는 NamadWorker 라는 폴더에 코드가 있다.