Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ var client = require('git-fetch-pack')()
✗ import client from 'git-fetch-pack'
Not an ESM module; no default export, factory function.
client
✓ var client = require('git-fetch-pack')()
Factory invocation returns client duplex stream.
Ref objects
✓ // Ref object structure documented in README
✗ var Ref = require('git-fetch-pack').Ref
No exported Ref class; refs are plain objects.
Shows how to clone/fetch using git-fetch-pack with net, transport, and repo loading.
var net = require('net');
var clientFactory = require('git-fetch-pack');
var transport = require('git-transport-protocol');
var load = require('git-fs-repo');
var walk = require('git-walk-refs');
load('/path/to/repo/.git', function(err, git) {
if (err) { console.error(err); return; }
var refs = git.refs();
var hashes = refs.map(function(x) { return x.hash; });
var tcp = net.connect({host: 'github.com', port: 9418});
var want = function(ref, ready) {
if (ref.name === 'refs/heads/master') { ready(true); } else { ready(false); }
};
var client = clientFactory(
'git://github.com/chrisdickinson/plate.git',
want,
walk(git.find, hashes)
);
client.refs.on('data', console.log);
client.pipe(transport(tcp)).pipe(client);
client.pack.pipe(process.stdout);
});
Errors
Common errors & fixes
Error: connect ECONNREFUSED 192.30.255.113:9418
Git protocol port 9418 blocked or host unreachable
fixUse SSH or HTTPS instead, or ensure firewall allows port 9418.
TypeError: client.pipe is not a function
Factory not invoked (missing parentheses)
fixCall the factory: var client = require('git-fetch-pack')(); Error: Not a git repository
Path to .git folder incorrect
fixProvide absolute path to the .git directory.
readable stream ended before packfile received
Side-band not supported, server response truncated
fixEnable capabilities or use different protocol.
Audit
Dependencies
git-transport-protocolrequiredrequired for TCP transport
git-fs-reporequiredneeded to load local repository refs
git-walk-refsoptionalused to generate have-stream for fetch