Skip to main content

6 posts tagged with "git"

View All Tags

wKevin

局域网内多人之间、个人多台电脑之间 —— 如何快速分享、互传 git 管理的代码?

  • 邮件?
  • ftp?
  • scp [-P <port>] <src-file> <user>@<ip>/<dst-file>
  • python -m http.server
  • npm install http-server -g then http-server <root/dir> [-p <port>] ?

上面都行,但文件要逐个传或打包,然后手工合并……不妨用 git 内置的 server 来处理:

$ git daemon

wKevin

发现若干 submodule 处于修改状态,想清理到初始状态。

$ git st
...
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: AI/ML-DL/100-Days-Of-ML-Code/100-Days-Of-ML-Code (new commits)
modified: AI/ML-DL/Andrew.Ng/machine-learning-yearning (new commits)
modified: AI/challenge/kaggle/cifar-10/CIFAR10_mxnet (modified content)
modified: AI/challenge/kaggle/cifar-10/cifar10-gluon (modified content)
modified: AI/challenge/kaggle/cifar-10/densenet.pytorch (modified content)

执行下面 4 类操作都都无法清理。

wKevin

对 git 的源码进行了一些分析,统计 Documentation/ 文件夹下的 git-xxx 命名的文件(即 git 命令的帮助文件)出现的版本号(tag),可以看出其生命周期,有些只出现一个版本就消亡掉了(git upload-tar),有些很晚才出现(git switch

wKevin

git help submodule 文档中找不到如何 mv 一个已有的 submodule,stackoverflow 上可以搜到很多这个问题的解决办法,大多和本文的内容一样,晦涩而繁杂,没办法,好像没有完美而简洁的办法。 本文只是分析 stackoverflow 上的解决办法,进行一些梳理和总结。

要素

重命名一个 submodule,要涉及以下几个方面:

  1. .gitmodules 1.1. .submodules 1.2. path
  2. .git/config //基本不需要修改
  3. .git/modules/ 3.1. oldPath/xxx/config -- worktree 3.2. oldPath/submodule --> newPath/submodule
  4. submodule/ 4.1. 创建 newPath/submodule 4.2. mv oldPaht/submodule/. --> newPath/submodule/ 4.3. newPath/submodule/.git -- gitdir 4.4. 删除 oldPath/submodule

wKevin

常规操作

发布者:维护父项目与 submodule 之间的依赖关系

$ git submodule add https://......
$ git commit

使用者:使用父项目,透明处理或更新 submodule,但不修改依赖关系

$ git clone https://github.com/wkevin/iOS.grocery.git
$ cd iOS.grocery
$ git submodule init
$ git submodule update