【问题标题】:What git commands do "hexo init <folder>" exactly do?“hexo init <文件夹>”究竟做了哪些git命令?
【发布时间】:2016-07-14 03:06:34
【问题描述】:

当我使用Hexo [https://hexo.io/]在github上部署静态博客时,我首先执行“hexo init”来初始化hexo文件夹以生成如下文件和文件夹:

.
├── _config.yml
├── package.json
├── 脚手架
├── 来源
| ├── _drafts
| └── _posts
└── 主题

但是,当我执行命令“hexo init”时,我发现它实际上执行了 git 命令:

  [root@localhost buwei]# hexo init blog
  INFO  Cloning hexo-starter to /home/buwei/blog
  Cloning into '/home/buwei/blog'...
  remote: Counting objects: 53, done.
  remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53
  Unpacking objects: 100% (53/53), done.
  Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-      landscape.git) registered for path 'themes/landscape'
  ....

所以我想知道“hexo init”执行了哪些git命令?

【问题讨论】:

    标签: git hexo


    【解决方案1】:

    来自hexojs/hexo-cli/lib/console/init.js#initConsole(),主要执行git clone

      if (args.clone) {
        promise = spawn('git', ['clone', '--recursive', GIT_REPO_URL, target], {
          stdio: 'inherit'
        });
      } else {
        promise = copyAsset(target);
    }
    

    然后它会删除 git 目录 (.git) 和模块 (.gitmodules)

      return promise.catch(function() {
        log.warn('git clone failed. Copying data instead');
    
        return copyAsset(target);
      }).then(function() {
        return Promise.all([
          removeGitDir(target),
          removeGitModules(target)
        ]);
      }).then(function() {
        if (!args.install) return;
    
        log.info('Install dependencies');
    
        return spawn('npm', ['install', '--production'], {
          cwd: target,
          stdio: 'inherit'
    });
    

    【讨论】:

      【解决方案2】:

      hexo init 在这里为您提供博客的主要结构。如果 git 命令可用,它将执行 hexo-starter 存储库的 git clone,否则,hexo-cli 复制其 submodule - assets @ 221419b 的副本,其中包含 hexo-starter 的源。

      【讨论】:

        猜你喜欢
        • 2012-07-10
        • 1970-01-01
        • 2020-11-15
        • 2020-12-09
        • 1970-01-01
        • 2021-01-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多