简体   繁体   中英

git add files to an orphan branch without parent directory

I am trying to push files for a Jekyll docs site into an orphan branch that will be maintained separately from the master:

git checkout --orphan gh-pages

I've added the file to a /site directory and from there I am trying to add those to my orphan branch:

git add site/ *

When I do that it adds all of the files and subdirectories to gh-pages/site, instead of gh-pages. Is there a way to submit all the contents of parent site to gh-pages without adding the parent directory?

After creating the orphan branch I needed to:

git rm -rf .

instead of:

git rm --cached -r .

then add my updated files and:

git push remote <orphan-branch-name>

This is surely a duplicate answer, however, I wanted to post my findings.

The obvious way would be to place the files into the repo root, not under site/ .

The branch already is a "logical" folder, in a way.

If you want you can always checkout a second branch in another working tree, so you can have both branches checked out simultaneously.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM