Hexo主题themes/ 文件夹无法提交到GitHub的解决方法

Hexo主题themes/ 文件夹无法提交到GitHub的解决方法

好久没写博客了
最近在家里闲着无聊想把hexo搭建的博客用git来托管实现电脑的同步管理
以前都是在笔记本电脑里写 现在回到家更喜欢用台式机
so 就有了这样的想法 🆗 现在开始折腾

一、遇到的问题

因为themes/hexo-theme-icarus也是从仓库里拉取下来的 他关联到了作者的git仓库
所以提交不上去

1
2
3
4
5
6
7
8
9
10
11
12
C:\Users\WeiLin\Desktop\weilin-liao.github (master -> origin)
λ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: themes/hexo-theme-icarus (modified content, untracked content)

no changes added to commit (use "git add" and/or "git commit -a")

二、解决方案

  1. 从暂存区删除该文件夹

    1
    git rm --cache themes/主题文件名

    比如我的是主题是 hexo-theme-icarus

    1
    git rm --cache themes/hexo-theme-icarus
  1. themes/hexo-theme-icarus/.git文件夹到放到位置 比方说桌面
    记得把 themes/hexo-theme-icarus/.gitignore里的 _config去掉
  1. git status查看当前状态

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    C:\Users\WeiLin\Desktop\weilin-liao.github (master -> origin)
    λ git status
    On branch master
    Your branch is up to date with 'origin/master'.

    Changes to be committed:
    (use "git restore --staged <file>..." to unstage)
    deleted: themes/hexo-theme-icarus

    Untracked files:
    (use "git add <file>..." to include in what will be committed)
    themes/
  2. 直接按步骤提交就行了

    1
    2
    3
    git add .
    git commit -m "add themes"
    git push

    后面再把刚刚的.git文件夹移动回去

    🆗🆗折腾完了 干饭去了

作者

Reself's

发布于

2021-02-04

更新于

2021-02-09

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×