1. 해결하고자 하는 것
2. 해결 방법
1. 해결하고자 하는 것
하나의 프로젝트가 너무 크면 sub project 단위로 다시 분리 하고 싶을 때가 있다.
2. 해결 방법
다음과 같이 git filter-branch를 사용하면 된다.
만약 Master Branch에 5개의 폴더가 있고 그중 3번째 폴더만 별도 git으로 뺀다고 생각해 보겠다.
(.pia-aws) ec2-user:~/environment/DevOps_Microservices (master) $ git filter-branch --prune-empty --subdirectory-filter ./Lesson-3-Containerization/ master
Rewrite 1d5fe1ddf5c5c07c4b1cf9df4eb532c01e0cb5bf (1/1) (0 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
javascript
git filter-branch --prune-empty --subdirectory-filter <<폴더명>> <<branch명>>
branch명에는 해당 폴더만 남기고 다른 폴더들은 삭제 되게 된다.
새롭게 만든 다른 git에 push하는 방법은 다음과 같다.
(.pia-aws) ec2-user:~/environment/DevOps_Microservices/Lesson-3-Containerization (master) $ git remote -v
origin https://github.com/udacity/DevOps_Microservices.git (fetch)
origin https://github.com/udacity/DevOps_Microservices.git (push)
(.pia-aws) ec2-user:~/environment/DevOps_Microservices/Lesson-3-Containerization (master) $ git remote set-url origin https://github.com/theyoung/Containerization.git
(.pia-aws) ec2-user:~/environment/DevOps_Microservices/Lesson-3-Containerization (master) $ git remote -v
origin https://github.com/theyoung/Containerization.git (fetch)
origin https://github.com/theyoung/Containerization.git (push)
(.pia-aws) ec2-user:~/environment/DevOps_Microservices/Lesson-3-Containerization (master) $ git push -u origin master
Username for 'https://github.com/theyoung/Containerization.git': theyoung2002@naver.com
Password for 'https://theyoung2002@naver.com@github.com/theyoung/Containerization.git':
Enumerating objects: 31, done.
Counting objects: 100% (31/31), done.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (31/31), 24.49 KiB | 4.90 MiB/s, done.
Total 31 (delta 0), reused 30 (delta 0)
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: https://github.com/theyoung/Containerization/pull/new/master
remote:
To https://github.com/theyoung/Containerization.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
(.pia-aws) ec2-user:~/environment/DevOps_Microservices/Lesson-3-Containerization (master) $ git branch
* master
javascript
기존 연결되어있던 remote를 새로만든 git project와 연결화 push처리 하면 된다.
728x90
반응형
'Software활용' 카테고리의 다른 글
Kubernetes Deployments No resources (0) | 2021.03.01 |
---|---|
ssh key를 이용한 github 접근 (0) | 2021.03.01 |
tomcat install on centos (0) | 2020.03.27 |
Redis Config Explain (0) | 2020.03.27 |
Postgresql 11 installation on Centos7 (0) | 2020.03.27 |