Github: Mirroring gh-pages to master

后端 未结 8 2103
伪装坚强ぢ
伪装坚强ぢ 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:23

    I'm adding further explanation to @denbuzze and @MCSDWVL answers.

    If you want to push both to master and gh-pages automatically each time you run git push origin, you probably want to add a Refspec to the git config of your repo.

    So, according to the git-scm book, you can add two RefSpecs, by adding two push values to the repo config file .git/config:

    [remote "origin"]
    url = https://github.com//
          fetch = +refs/heads/*:refs/remotes/origin/*
          push = refs/heads/master:refs/heads/master
          push = refs/heads/master:refs/heads/gh-pages
    

    That will cause a git push origin to:

    1. Push the local master branch to the remote master branch
    2. Push the local master branch to the remote gh-pages branch

    by default.

    Note: using a + before the spec causes to force push to the repo. Use it with caution:

    The format of the refspec is an optional +, followed by :, where is the pattern for references on the remote side and is where those references will be written locally. The + tells Git to update the reference even if it isn’t a fast-forward.

提交回复
热议问题