0

我正在寻找一种方法来查看 git 裸存储库中由其他远程更新但不拉入我的存储库的文件。

我将尝试使用本地示例来描述我的疑问。

我创建了一个文件夹,添加了两个文件并创建了一个新的存储库。

> mkdir stackOF && cd stackOF
> touch file1 file2
> git init

然后我从这个 repo 创建一个裸存储库。

> cd .. && git clone --bare stackOF stackOF.git

现在我想创建该裸仓库的两个克隆并模拟太同事的一些操作。

> git clone stackOF.git stackOF.clone1
> git clone stackOF.git stackOF.clone2

首先,clone1将创建一个文件,提交并推送更改。

> cd stackOF.clone1 && touch file_clone1
> git add . && git commit -m "File from clone 1."
> git push

其次,clone2将创建一个文件并且只提交。

> cd ../stackOF.clone2 && touch file_clone2
> git add . && git commit -m "File from clone 2."

在这一点上,我开始怀疑这个ls-tree概念。执行下一个命令,我希望看到 clone1 推送的文件,但我收到以下信息:

> git ls-tree origin
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file2

我想收到类似在裸存储库目录中执行 ls-tree 命令的结果:

> cd ../stackOF.git
> git ls-tree master
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file2
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file_clone1

研究这个案例,我发现了一个命令,它向我展示了我想要的东西,但还有很多其他信息。因此,返回clone2并执行命令:

> cd ../stackOF.clone2
> git archive -v --remote=file:///f/gits/stackOF.git master
pax_global_header00006660000000000000000000000064133246307500014515gustar00rootroot0000000000000052 comment=0085439d6a07481e6a21db545edd3f7960c038e2
file1000066400000000000000000000000001332463075000117720ustar00rootroot00000000000000file2000066400000000000000000000000001332463075000117730ustar00rootroot00000000000000file_clone1000066400000000000000000000000001332463075000131520ustar00rootroot00000000000000remote: file1
remote: file2
remote: file_clone1

总而言之,我在clone2存储库中查看哪些文件在裸存储库中,而无需拉取。但我想要一些非常干净的东西,比如ls_tree在裸存储库上使用。

4

0 回答 0