用Github Pages为自己的帐号搭建个人主页时添加CNAME到github仓库会遇到很多问题:
1.通过$ git push -u origin master命令把CNAME文件推送到远程库时出现如下错误:
To github.com:xxxxxxxx/xxxxxxx.github.io
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:xxxxxxx/xxxxxxxx.github.io'
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.
[xxxxxxx处表示自己的github账号]【主要原因是github中的CNAME文件不在本地代码目录中】
解决办法:
使用git pull --rebase origin master进行代码的合并。
接着我在使用上述命令时又出现了如下错误:
error: cannot pull with rebase: You have unstaged changes.
error: additionally, your index contains uncommitted changes.
【这个问题的原因是有未提交的更改】
输入如下命令解决:
git stash //暂时存放当前正在执行的操作
git pull –rebase
git stash pop //从Git中读取最近一次保存的内容
即可解决问题。
2.未对域名添加解析:
在控制台的云解析DNS中找到自己的域名点击域名设置,进入域名设置界面,点击添加域名,选择主机记录WWW或@,记录写为自己个github仓库的ip地址。