git status git add themes/ git commit -m "add AAAAA_business again" git remote add origin git@github.com:HysenEcho/Hexoblog.git git push origin main
新建脚本
每次推送都要输入这三条命令,你可能觉得有些麻烦。那么你可以编写 bash 脚本。
譬如,在根目录下新建 update.sh。
1 2 3 4 5 6 7 8
# 如果没有消息后缀,默认提交信息为 `:Hysen: update content` info=$1 if ["$info" = ""]; then info=":Hysen: update content" fi git add -A git commit -m "$info" git push origin master
此后更新的话,只需要在终端执行 sh update.sh 即可。
出现问题
问题1:git add报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14
warning: adding embedded git repository: themes/hexo-theme-huhu hint: You've added another git repository inside your current repository. hint: Clones of the outer repository will not contain the contents of hint: the embedded repository and will not know how to obtain it. hint: If you meant to add a submodule, use: hint: hint: git submodule add <url> themes/hexo-theme-huhu hint: hint: If you added this path by mistake, you can remove it from the hint: index with: hint: hint: git rm --cached themes/hexo-theme-huhu hint: hint: See "git help submodule" for more information.
$ git push --set-upstream origin hexo error: src refspec hexo does not match any error: failed to push some refs to 'https://github.com/HysenEcho/HysenEcho.github.io'
后来重新输入,改为master,还是报错
1 2
$ git push --set-upstream origin master fatal: unable to access 'https://github.com/HysenEcho/HysenEcho.github.io/': Recv failure: Connection was reset