push local master *into* gh-pages branch on github

前端 未结 4 746
陌清茗
陌清茗 2021-02-01 05:45

I created a simple gh-pages branch on github and in my local repo. I used the auto page generator to create the 5 files it uses: images javascripts stylesheets index.h

相关标签:
4条回答
  • 2021-02-01 06:38

    From what I understand, you'd have to switch to your local copy of gh-pages. Merge in master, and then push gh-pages

    git checkout gh-pages
    git merge master
    git push origin gh-pages
    
    0 讨论(0)
  • 2021-02-01 06:40

    If I understand you correctly it seems that you created the dummy Readme and the other files on your local master branch but intended to have them on the gh-pages branch. If thats the case, the safest option is to merge your master branch into the gh-pages branch (assuming you dont have other files on master you would rather not have on the gh-pages branch). The command suggested git push -f origin master:gh-pages will push your local master branch to the gh-pages branch. I'm not really sure what you mean but into vs onto, as branch names are just pointers in git.

    0 讨论(0)
  • 2021-02-01 06:40

    as an alternative approach, how about using a git subtree to serve as your gh-pages branch?

    git checkout master
    git subtree push --prefix . origin gh-pages
    

    according to the git-subtree docs on the source code:

    Subtrees allow subprojects to be included within a subdirectory of the main project, optionally including the subproject's entire history.

    in our case, we may be able to alias the same path (the root path; .) as a virtual copy of the master branch (i have not tested it, though).

    by the way, i found out about subtrees after encountering this gist, by cobyism.

    0 讨论(0)
  • 2021-02-01 06:51

    Here is a good writeup github pages workflow that I used to understand how to interact between the master and gh-pages branches.

    paul irish from google recommended it in the comments of another article- it had super clear examples.

    0 讨论(0)
提交回复
热议问题