Git clone --no-checkout 再次

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33104540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:27:13  来源:igfitidea点击:

Git clone --no-checkout again

gitgit-clone

提问by user2087045

I don't want to waste space on my machine and I only want to see the history of repository (for each branch). That's why, I did a:

我不想在我的机器上浪费空间,我只想查看存储库的历史记录(对于每个分支)。这就是为什么,我做了一个:

    git clone --no-checkout

After I did this, somebody pushed something. I have to do something to be again with the history updated, but I don't know what. Of course, I can use git checkout & git pull, but I don't need the files, I need only the .git folder to be updated. I tried with git fetch, but it seems the history is not updated.

在我这样做之后,有人推动了一些东西。我必须做一些事情才能再次更新历史记录,但我不知道是什么。当然,我可以使用 git checkout 和 git pull,但我不需要这些文件,我只需要更新 .git 文件夹。我试过 git fetch,但似乎历史没有更新。

回答by user3159253

Use --bareoption for git clone

使用--bare选项git clone

Update:

更新

after the cloning is completed make sure that the section remote.originin the configuration (see configfile in the repo) contains fetchkey with an appropriate. The section should look like this:

克隆完成后,请确保remote.origin配置中的部分(请参阅configrepo 中的文件)包含fetch具有适当密钥的密钥。该部分应如下所示:

[remote "origin"]
    url = <upstream repo remote address>
    fetch = +refs/heads/*:refs/remotes/origin/*

Then you may update the repo from time to time by issuing git fetchinside the repo.

然后你可以不时通过git fetch在 repo 内部发布来更新repo。