我一直在使用git subtree一段时间,但最近遇到了git subrepo并想切换。我承认这个项目仍处于早期阶段,但评论表明它已经足够稳定,可以生产大约几年。
我无法开始使用,我不确定这是不兼容问题、设置不当还是其他原因。我希望这里的人有他们可以分享的经验。
首先,我运行的是 Windows 10 和 Git 版本 2.23.0.windows.1。文档表明我应该很好。我克隆了 repo,然后在 Git 中成功运行了一些命令
$ source /path/to/git-subrepo/.rc
$ git subrepo --version
0.4.3
然后我sub_a
通过my_project
从. 这个 subrepo 有预期的文件和git-subrepo 添加的文件。git subrepo clone <path_to_sub_a>
my_project
.gitrepo
现在,如果我sub_a
从内部进行更改my_project
并尝试推动更改,我会遇到问题。
$ git subrepo push sub_a
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
git-subrepo: Command failed: 'git branch subrepo/sub_a '.
fatal: Not a valid object name: ''.
另外,如果我对 GitHub 上的 repo 进行上游更改sub_a
并尝试将其拉到my_project
,我会收到类似的错误。
$ git subrepo pull workshop
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
git-subrepo: Command failed: 'git branch subrepo/sub_a '.
fatal: Not a valid object name: ''.
或者用调试
$ git subrepo pull sub_a -vd
>>> git rev-parse --verify HEAD
* Assert that working copy is clean: /path/to/my_project
* Check for worktree with branch subrepo/sub_a
* Fetch the upstream: https://github.com/USER/sub_a.git (master).
>>> git fetch --no-tags --quiet https://github.com/USER/sub_a.git master
* Get the upstream subrepo HEAD commit.
>>> git rev-parse FETCH_HEAD^0
* Create ref 'refs/subrepo/sub_a/fetch'.
>>> git update-ref refs/subrepo/sub_a/fetch 7bacf57d882080a2ccc37efdda0a6082a3f05f29
* Deleting old 'subrepo/sub_a' branch.
* Remove worktree:
>>> git branch -D subrepo/sub_a
* Create subrepo branch 'subrepo/sub_a'.
* Check if the 'subrepo/sub_a' branch already exists.
* Subrepo parent: 2eb400c748396c9ff12b95d9e903034cabc8a5b6
* Create new commits with parents into the subrepo fetch
>>> git rev-list --reverse --ancestry-path --topo-order 2eb400c748396c9ff12b95d9e903034cabc8a5b6..HEAD
* Working on 77642972dbf6499abec6ba1a9ded291caa752243
>>> git config --blob 77642972dbf6499abec6ba1a9ded291caa752243:sub_a/.gitrepo subrepo.commit
* .gitrepo reference commit: cf11b7f544a98a628626186214e724967077529d
* Check for rebase
* Find parents
* Create a new commit -p cf11b7f544a98a628626186214e724967077529d
>>> git cat-file -e 77642972dbf6499abec6ba1a9ded291caa752243:sub_a
* Create with content
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
* Working on da57a18de8221595df94d635628531f520155453
>>> git config --blob da57a18de8221595df94d635628531f520155453:sub_a/.gitrepo subrepo.commit
* .gitrepo reference commit: cf11b7f544a98a628626186214e724967077529d
* is child: 77642972dbf6499abec6ba1a9ded291caa752243
* Check for rebase
* Find parents
* Create a new commit
>>> git cat-file -e da57a18de8221595df94d635628531f520155453:sub_a
* Create with content
\path\to\git-subrepo\lib\git-subrepo: line 786: /dev/fd/62: No such file or directory
fatal: empty ident name (for <>) not allowed
* Create branch 'subrepo/sub_a' for this new commit set .
>>> git branch subrepo/sub_a
git-subrepo: Command failed: 'git branch subrepo/sub_a '.
fatal: Not a valid object name: ''.
如果我们无法在此处解决问题,我也会将其作为问题发布在 GitHub 页面上供开发人员使用。