如何将git存储库的COPY(存档,而不是克隆)连接到其远程? [英] How do I connect a COPY (an archive, not a clone) of a git repository to its remote?

查看:107
本文介绍了如何将git存储库的COPY(存档,而不是克隆)连接到其远程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



背景:$($)$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $背景:
我有一个本地和远程存储库。我使用git archive压缩了我的本地存储库,然后将它复制到服务器:

  $ git archive --format = tar HEAD | gzip> myarchive.tar.gz 

问题:
解压缩服务器上的存档后,我再次连接并同步服务器的副本与远程存储库?



如果我这样做:

  $ git init 
$ git remote add origin git@github.com/myusername:reponame.git
$ git fetch origin

git状态仍会将所有内容报告为未跟踪。



我应该做些什么,以便我的解压缩文件夹与远程仓库完全同步,因此我可以简单地将未来的任何提交到远程回购?



非常感谢,
Tim

解决方案

做一个存档:做一个 git bundle :这会为您提供一个文件,但只要在远程位置复制,您就可以从中拉取



请参阅如何通过电子邮件向某人发送git存储库?



该包也可以是增量包的(另请参阅 git包和.patch之间的区别)。
表示您不必通过完整 repos复制,仅复制自上次备份以来缺少的提交。



我有一个脚本,可以在我的所有裸回购版中完成每周一次的完整备份,每天进行增量备份(如果检测到新提交): sbin / save_bundles




正如 Nevik Rehnel 提到在评论中,git档案只会保存一个修订,这将使远程仓库中的任何同步不完整(缺少中间提交)。

另一种方法是以 tar全部回购,但包括太多(包括可能的私人敏感文件或挂钩脚本)。 git bundle 是git方式。


I'd like to know to connect and sync a COPY (an archive, not a clone) of a git repo with its remote repo.

Background: I have a local and remote repository. I zip up my local repository using git archive and then copy it to a server:

$ git archive --format=tar HEAD | gzip > myarchive.tar.gz

Question: After unzipping the archive on the server, how do I connect and sync the server's copy with the remote repository again?

If I do this:

$ git init
$ git remote add origin git@github.com/myusername:reponame.git
$ git fetch origin

git status still reports everything as being untracked.

What should I be doing so that my unzipped folder is perfectly in sync with the remote repo, and so I can simply pull any future commits to the remote repo?

Many thanks, Tim

解决方案

Don't do an archive: do a git bundle: that will give you one file, except you will be able to pull from it once copied in the remote location.

See more at "How can I email someone a git repository?"

That bundle can be incremental too (see also "Difference between git bundle and .patch").
Meaning you don't have to copy over the full repos, only the missing commits since the last backup.

I have a scripts which goes to all my bare repos and make a full backup once a week, incremental backups every day (if new commits are detected): sbin/save_bundles.


As Nevik Rehnel mentions in the comments, git archive would only save one revision, which would make any synchronization in the remote repo incomplete (missing intermediate commits).

Another approach is to tar the all repo, but that includes too much (including possible private sensitive files, or hook scripts). git bundle is the git way.

这篇关于如何将git存储库的COPY(存档,而不是克隆)连接到其远程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆