GitHugo 修整问题

Fri, Jun 19, 2020 2-minute read
fatal: not a git repository (or any of the parent directories): .git

最好的方式还是事先建设好远程仓库,导入文件,不然真的会出现很多问题。

$ git submodule add -b main https://github.com/xxx/xxx.github.io.git public
fatal: not a git repository (or any of the parent directories): .git
error: src refspec blog does not match any
Administrator@PC-1 MINGW64 /f/hugo/xxx (master)
$ git push -u remote blog main
error: src refspec blog does not match any
error: src refspec main does not match any
error: failed to push some refs to 'remote'
Administrator@PC-1 MINGW64 /f/hugo/xxx (master)
$ git push origin main
error: src refspec main does not match any
error: failed to push some refs to 'branch'
fatal: ‘branch’ does not appear to be a git repository

删不了远程分支

Administrator@PC-1 MINGW64 /f/hugo/xxx (master)
$ git push origin --delete master
fatal: 'branch' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remote -v
main    git@github.com:rileyshen/blog.git (fetch)
main    git@github.com:rileyshen/blog.git (push)
origin  branch (fetch)
origin  branch (push)
Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git push main --delete master
To github.com:rileyshen/blog.git
 - [deleted]         master

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remove origin
git: 'remove' is not a git command. See 'git --help'.

The most similar command is
        remote

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remote remove main

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remote add origin git@github.com:rileyshen/blog.git
fatal: remote origin already exists.

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remote remove origin

Administrator@PC-1 MINGW64 /f/hugo/RileyCode (master)
$ git remote add origin git@github.com:rileyshen/blog.git