简体   繁体   中英

Automatically deploy git on servers not reachable

I have several servers that can't be reach via SSH or HTTP directly but they are able to connect to internet.

I would like to find a smart way to deploy automatically updates via git. I could do a script that periodically do a git pull but it seems not the best way.

Which is the best way to manage git deploy in this scenario?

You might want to look into "git bundle"

I have used this in "air gapped" systems before.

git bundle create <file> <git-rev-list-args>

git bundle verify <file>

Once you create the bundle, you can use "git clone" or "git pull" against the bundle.

This is from the man page for "bundle":

Some workflows require that one or more branches of development on one machine be replicated on another machine, but the two machines cannot be directly connected, and therefore the interactive Git protocols (git, ssh, rsync, http) cannot be used. This command provides support for git fetch and git pull to operate by packaging objects and references in an archive at the originating machine, then importing those into another repository using git fetch and git pull after moving the archive by some means (eg, by sneakernet). As no direct connection between the repositories exists, the user must specify a basis for the bundle that is held by the destination repository: the bundle assumes that all objects in the basis are already in the destination repository.

you just need to copy the bundle to a machine that you can reach from the other system and then copy the file over and just do a git pull from the bundle

Git 2.25 (Q1 2020) explains why.

See commit 0e40a73 (20 Oct 2019) by Philip Oakley ( PhilipOakley ) .
(Merged by Junio C Hamano -- gitster -- in commit 7c88714 , 10 Dec 2019)

Doc : Bundle file usage

Signed-off-by: Philip Oakley

Improve the command description, including paragraph spacing.

Git URLs can accept bundle files for fetch, pull and clone, include in that section. Include git clone in the bundle usage description. Correct the quoting of <git-rev-list-args> .

Detail the <git-rev-list-args> options for cloning a complete repo.

So the updated git bundle documentation now includes:

The ' git bundle ' command packages objects and references in an archive at the originating machine, which can then be imported into another repository using ' git fetch ', ' git pull ', or ' git clone ', after moving the archive by some means (eg, by sneakernet).

Also:

git clone can use any bundle created without negative refspecs (eg, new , but not old..new ).
If you want to match git clone --mirror , which would include your refs such as refs/remotes/* , use --all .
If you want to provide the same set of refs that a clone directly from the source repository would get, use --branches --tags for the <git-rev-list-args> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM