2016-08-18 2 views
4

그래서 github recently implemented a feature to use the docs/ directory of master instead of gh-pages. 그리고 이것은 내 같은 일부 유스 케이스에 좋습니다.힘내 : gh 페이지 분기의 내용을 문서/디렉토리에 저장하는 방법?

시나리오는 master와 자식의 repo와 gh-pages 지점 (GitHub의 페이지를하는 "오래된"방법)이고, I는 (masterdocs/ 디렉토리에 gh-pages 지점에서 "새"를 모든 이동하려면 github 페이지를하는 방법).

나는 git checkout master; git checkout gh-pages -- docs을 사용할 수 있다는 것을 알고 있지만 바람직하지 않은 파일 인 gh-pages에서 기록을 삭제합니다.

나는 git subtreegit filter-branch으로 아무렇지도 않게 뛰어 들었다.

질문 : 내역을 유지하면서 다른 분기의 내용을 하위 디렉토리로 이동하는 마법 1 회선 git 명령이 있습니까?

답변

0

한 줄의 명령이있는 경우 나도 몰라,하지만 당신은 REBASE를 시도하고 마스터에 병합 수 :

git checkout gh-pages 
git rebase master 
git checkout master 
git merge --no-ff gh-pages 
+0

* 문서 /'첫째. 그러나'gh-pages '의 분기는 2011 년으로 거슬러 올라가며 병합 충돌은 거대합니다. – IvanSanchez

0

내가 어떤 마법 하나를 찾을 수 없습니다 - 라이너,하지만 git merge (다시 한번 그 옵션을 시도 향해 내게 영감을위한 @ Wikiti)를하고 일을하는 것 같았다.

내가 뒤 따르는 마지막 방법은 꽤 아니며 git reset 횟수만큼 실행해야합니다.

이것은 완벽하지 않으며 모든 전문가 또는 gitlab 직원이 더 나은 솔루션을 제안하도록 권장합니다. 그것은 다른 사람들이 멀리 gh-pages 지점에서 이동하려고 도움이 될 것입니다 희망에서, 이것은 내가 그것을 어떻게입니다 :

git checkout master 
git checkout -b master-docs 
git merge gh-pages 

# Reset the "master" files so that files deleted are left untouched by the merge 
git reset src/ 
git checkout src/ 
git reset any-other-master-files 
git checkout any-other-master-files 

# Manually edit any conflicts, e.g. in .gitignore (with your favourite editor) 
vi .gitignore 
git add .gitignore 
vi any-other-conflicting-files 
git add any-other-conflicting-files 

# Move the "gh-pages" files into "docs/" directory 
mkdir docs 
git mv *.md docs/ 
git mv *.html docs/ 
git mv _posts docs/ 
git mv _layout docs/ 
git mv any-other-gh-pages-files docs/ 

# Check that everything looks OK, there should be only files added to docs/ 
# If not, go through last steps again 
git status 

# Confirm the merge 
git commit 

# Push to origin 
git push -u master-docs 

# Go to github, make a pull req from master-docs to master for peer review 

합니다 (result doesn't look bad)

1

git subtrees이 이상적입니다. 당신은 그들과 함께 "바이올린"언급,하지만 당신은 시도했다 :

git subtree add --prefix=docs origin gh-pages 

체크 아웃 내 docs-subtree branch 나는`자식 MV로, 그 시도했다

관련 문제