Git clone --bare / fetch [英] Git clone --bare / fetch
问题描述
我有一个拥有悠久历史的git仓库。我不知道开发人员用这个仓库做了什么,并且无法控制他们现在在做什么。
但是我需要克隆这个仓库(用于redmine集成)并定期获取所有更改。
我该做什么:
git clone --bare git@git.server.com:/ opt / git / repo
cd repo.git
git log
现在我可以看到所有提交。很好。
接下来,开发人员在主存储库中进行提交,并且我想要获取所有更改(所有更改,标签等等): p>
> git fetch --all
获取原点
remote:计数对象:18,完成。
remote:压缩对象:100%(14/14),完成。
remote:合计14(delta 5),重用0(delta 0)
开箱对象:100%(14/14),完成。
从git.gmcs.ru:/opt/git/ecco
*分支HEAD - > FETCH_HEAD
但是如果有人提出提交历史记录,我没有看到最后一次提交是在主要存储库。为什么?
如果我没有发布足够的信息,我已准备好给您提供所有必需的信息。
$ b
更新
以下是原始资料中的简要资讯:
git branch -a
one
test
* master
release
以下是克隆库中的分支信息:
git branch -a
one
test
* master
release
我可以在原始存储库的主分支中看到最后提交的内容,但无法在克隆存储库的主分支中找到它们。
你应该使用
git pull
或在运行后运行 git merge
以获取提取的更改
如果您有裸仓库,则无法执行提取,因为一个拉要和HEAD合并,而裸回购没有您可以将它作为远程
添加到非裸存储库并推送到它。 。
但我认为 - 镜像
而不是 - bare
将按原样为你工作。
$ b
与--bare相比,--mirror不仅将
源的本地分支映射到目标的本地分支,它映射所有refs(包括
远程分支,注释等)并设置一个refspec配置,例如
,所有这些refs被
目标库中的git远程更新覆盖。您可以使用git remote update
来更新镜像存储库
I have a git repository with long and strange history. I don't know what the developers did with this repository and cannot control what they are doing with it now.
But I need to clone this repository (for redmine integration) and fetch all changes periodically.
What do I do:
git clone --bare git@git.server.com:/opt/git/repo
cd repo.git
git log
Now I can see all commits. Fine.
Next a developer make a commit in the main repository and I want to fetch all changes (all brances, tags and so on, and so on):
> git fetch --all
Fetching origin
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 14 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (14/14), done.
From git.gmcs.ru:/opt/git/ecco
* branch HEAD -> FETCH_HEAD
But if a ask the commit history I didn't see that last commit which was made in the main repository. Why ?
If I post not enough information I am ready to give you all the needed.
Thanks in advance.
Updated
Here is a brach information in the original repsitory:
git branch -a
one
test
* master
release
Here is a branch information in the cloned repository:
git branch -a
one
test
* master
release
I can see last commits in the master branch of original repository, but can not find them in the master branch of cloned repository.
You should use git pull
or run git merge
after fetch to get fetched changes
if you have a bare repository you can not do a pull, because a pull wants to merge with HEAD, which a bare repo does not have.
to update bare repository you can add it as remote
to non-bare repository and push to it.
But I think --mirror
instead of --bare
will work for you as is.
Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.
and then you can use git remote update
to update mirrored repository
这篇关于Git clone --bare / fetch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!