利用GitHub免费的静态页面托管空间发布网页
A、提前登陆github创建一个New repository(例如,test01)
B、再创建一个新的token
https://github.com/settings/tokens
Create New Tokens (classic)
------------------------------------------
1、编写好网页及相关文件代码(html、css、图片等)
2、使用cd命令进入网页文件夹
3、依次执行git命令:
vi .gitignore
写入下面的内容(告诉github哪些文件不用上传)并保存退出。
# 依赖目录
node_modules/
# Next.js 构建产物
.next/
git init
git remote add origin https://github.com/zhangfanxp/test01.git
git add .
git commit -m "Initial commit"
git branch -M main
设置翻墙:
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
确保命令行可以正常翻墙后,再执行:
git push -u origin main
提示行中输入用户名(zhangfanxp)和之前创建的token
如果提示错误,运行新的命令:
git push https://zhangfanxp@github.com/zhangfanxp/huashu.git
把生成的Token拷贝进来即可(ghp_QUmhnti****zKy40v4FAa)
4、设置Github Pages页面:
选择 main 分支,目录选择 /(root) (默认 root)
每次更新后执行:
git pull origin main --rebase (先把远程的文件拉取到本地)
git add .
git commit -m "Update"
git push
https://zhangfanxp.github.io/test01/
如果是Axure原型,则访问:
https://zhangfanxp.github.io/test01/start.html
正常访问网页了!
a、使用cd命令进入项目文件夹;
------------------------------------------------
服务器/本机要更新github的时候,可以在原有项目的文件夹下强制拉取更新
cd test01
git branch
git checkout .
git pull
-------------------------------------------------
当运行下面的命令:
git remote add origin https://github.com/zhangfanxp/videoList_New.git
返回错误:
错误:远程 origin 已经存在。
把原命令改为:
git remote set-url origin https://github.com/zhangfanxp/videoList_New.git
评论
发表评论