Github: Mirroring gh-pages to master

后端 未结 8 2053
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 09:27

I\'m developing a jQuery plugin that\'s being hosting on GitHub. It has a demo included of which I\'m manually copying and pushing to the branch gh-pages, what

相关标签:
8条回答
  • 2020-12-12 10:00

    commit and push to master..

    then :

    git checkout gh-pages  // -> go to gh-pages branch
    git rebase master // bring gh-pages up to date with master
    git push origin gh-pages // commit the changes
    git checkout master // return to the master branch
    
    0 讨论(0)
  • 2020-12-12 10:01

    Do not do what denbuzze suggests above!! The + (plus sign) in the push makes it quietly accept non-fastforward updates. I found out the hard way that this can irrevocably cause work to be lost by leading to dangling commits. Simply removing the plus signs makes this a safer approach.

    push = refs/heads/master:refs/heads/gh-pages
    push = refs/heads/master:refs/heads/master
    

    now instead of causing a force update this will cause a warning & pull suggestion

    To https://github.com/someuser/repo.git
     ! [rejected]        master -> gh-pages (fetch first)
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'https://github.com/someuser/repo.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    
    0 讨论(0)
  • 2020-12-12 10:11

    OR you can just use the cmd below, this will push your local master branch to gh-pages master branch. git push -f origin master:gh-pages

    0 讨论(0)
  • 2020-12-12 10:12

    Add the following 2 lines to the [remote "origin"] section of .git/config:

    push = +refs/heads/master:refs/heads/gh-pages
    push = +refs/heads/master:refs/heads/master
    

    Every time you push it will automatically push master to gh-pages as well. I'm using this for the jQuery Lifestream project.

    0 讨论(0)
  • 2020-12-12 10:15
    git checkout gh-pages
    git merge master
    git push origin gh-pages
    
    0 讨论(0)
  • 2020-12-12 10:22

    I personally like to wrap this in an alias:

    alias gpogh="git checkout gh-pages && git merge master && git push origin gh-pages && git checkout -"
    

    This mirrors your master to gh-pages, pushes to github, then switches back the previous branch you were working on.

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