git - 如何基于 gh-pages 分支创建主分支?

标签 git github

我克隆了一个只有分支 gh-pages 的 Jekyll 主题。我通过将所有更改推送到 gh-pages 分支来完全自定义主题。现在我想知道我可以从 gh-pages 分支创建一个主分支吗?如果可以,我会怎么做?

我希望我的问题有意义,因为我是 git 新手。

最佳答案

要基于本地 gh-pages 分支创建新的本地 master 分支,可以使用以下命令:

git checkout gh-pages     # switch to the gh-pages branch
git branch -d master      # delete current (old) local master branch
git checkout -b master    # create new master from gh-pages and switch to it

请记住,第二个命令将删除您的本地 master 分支,以便为您要创建的新分支腾出空间。因此,如果您已经有一个本地 master 分支,您应该确保您确实想要替换它。

如果您想基于远程 gh-pages 分支创建新的本地master 分支,可以使用以下命令:

git checkout gh-pages                     # switch to the gh-pages branch
git branch -d master                      # delete current (old) local master branch
git checkout -b master origin/gh-pages    # create new master from gh-pages

关于git - 如何基于 gh-pages 分支创建主分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32644031/

相关文章:

git - 如何在 GitHub 中 stash SVG 差异(或将 SVG 显示为图像)

git - 仅针对我的提交进行交互式 rebase

git - Bitbucket 事件图

GIT 错误 : fatal:/usr/libexec/git-core/git-submodule cannot be used without a working tree

git - 更改日志的自定义 git merge union 策略

git - 将 Visual Studio (2013) 中的文件重命名传播到 GIT 作为 GIT 重命名?

git - 如何在 git 中标记多个提交

git - 无法将 git 推送到远程存储库 : (SSH error)

github - GitHub Wiki 上的语法突出显示不起作用

git rm --cached 仍然将文件留在存储库中的某个位置