이 자식 저장소에 새로운 "루트"브랜치를 정의하고 싶습니다. "루트"분기 란 저장소 1 의 다른 모든 분기와 완전히 독립적 인 분기를 의미합니다 .
불행히도, Arepo의 커밋 트리의 맨 아래에 있는 커밋 (이것을 호출하자)조차 많은 파일을 포함합니다 (이것은 이미 상당히 성숙한 프로젝트에서 초기화 된 저장소였습니다).
이것은 내가 A새로운 브랜치로 주었다고해도이 <start-point>새로운 브랜치는 "클린 슬레이트"에서 시작하는 것이 아니라에 커밋 된 모든 파일을 포함한다는 것을 의미합니다 A.
이 리포지토리에 가능한 한 <start-point>가깝게 완전히 베어 브랜치를 만들 수있는 방법이 A있습니까?
1 BTW, 이것은 새로운 저장소를 만드는 것과 동등 하지 않습니다 . 여러 가지 이유로 별도의 repos가 덜 편리합니다.
편집 : 좋아, 이것은 vcsjones 의 답변 에 따라 내가 한 일입니다 .
# save rev of the current earliest commit
OLDBASE=$(git rev-list --max-parents=0 HEAD)
# create a new orphan branch and switch to it
git checkout --orphan newbranch
# make sure it's empty
git rm -rf .
# create a new empty commit in the new branch, and
# save its rev in NEWBASE
git commit --allow-empty -m 'base commit (empty)'
NEWBASE=$(git rev-list HEAD)
# specify $NEWBASE as the new parent for $OLDBASE, and
# run filter-branch on the original branch
echo "$OLDBASE $NEWBASE" > .git/info/grafts
git checkout master
git filter-branch
# NOTE: this assumes that the original repo had only one
# branch; if not, a git-filter-branch -f <branch> command
# need to be run for each additional branch.
rm .git/info/grafts
이 절차는 다소 복잡하지만 최종 결과는 새로운 "클린 슬레이트 브랜치"의 역할을 할 수 있는 빈 기본 커밋입니다 <start-point>. 그때해야 할 일은
git checkout -b cleanslate $(git rev-list --max-parents=0 HEAD)
앞으로 나는 항상 다음과 같은 새로운 저장소를 만들 것입니다.
git init
git commit --allow-empty -m 'base commit (empty)'
... 첫 번째 커밋이 비어 있고 항상 새로운 독립 브랜치를 시작할 수 있습니다. (이것은 매우 드물게 필요한 시설이지만, 쉽게 이용할 수있게 만드는 것은 쉽지 않습니다.)
git rebase --onto참조 stackoverflow.com/questions/645450/...