Reputation: 3144
Let's say I have a master
branch and a gh-pages
branch. The directory structure for master looks like this:
projects/
project-one/
src/
app.js
dist/
bundle.js
index.html
project-two/
src/
app.js
dist/
bundle.js
index.html
The directory structure for gh-pages
is blank, but I want it to look like this:
project-one/
bundle.js
index.html
project-two/
bundle.js
index.html
I've tried instructions detailed here
$ git checkout master
$ git checkout gh-pages project-one/dist
error
$ git checkout gh-pages -- project-one/dist
error
That should copy the dist folder into the gh-pages
branch but I get a error pathspec: file not found
error so I tried git pull
to sync to the remote, but this does not solve the problem.
Note that in order to make gh-pages
clean I used git rm -r
on the whole directory because I do not want gh-pages
directory structure to be inherited from master
.
How can I copy everything in each project/dist folder from the master branch into the gh-pages branch?
edit: tried git checkout gh-pages project-one/dist/**
which gave me a better error msg: error: pathspec 'dist/bundle.js' did not match any file(s) known to git.
Upvotes: 2
Views: 1289
Reputation: 5862
You're doing it backwards. You need to be in the scope of the gh-pages
branch and then do your checkout
operations:
$ git checkout gh-pages
$ git checkout master dir/file1
I believe the only way you could copy from a branch to another branch and change directory (without of course doing the manual work after the copy) would be the following:
$ git show master:dir/file1 > new_location/file1
Upvotes: 2