npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

git-syncd

v1.7.6

Published

Sync a target git branch tip via clone/fetch/fast-forward; Windows-safe worktree materialization

Readme

git-syncd

Keep a target branch in sync via git fetch + fast-forward (and git clone when needed). Never checks out or switches your current branch.

Available in: 中文 | Deutsch | Español | Français | 日本語

Installation

npm install git-syncd

Usage

import gitSyncd from "git-syncd";

// Sync target branch `main` (default) in the current working directory
const updated = await gitSyncd();

// Sync a specific directory
const updated = await gitSyncd({ cwd: "/path/to/repo" });

// Clone if missing, then keep the target branch in sync
const updated = await gitSyncd({
  cwd: "/path/to/repo",
  url: "https://github.com/org/repo.git",
});

// Target branch (default: main). Independent of the current checkout.
const updated = await gitSyncd({
  cwd: "/path/to/repo",
  url: "https://github.com/org/repo.git",
  branch: "develop",
});

// Even if HEAD is on `dev`, this advances local `main` to origin/main
// without checking out `main`.
const updated = await gitSyncd({ cwd: "/path/to/repo" });

// When the target tip differs and fast-forward fails, force-align (default)
const updated = await gitSyncd({ cwd: "/path/to/repo", force: true });

if (updated) {
  console.log("Target branch tip moved");
} else {
  console.log("Target branch already up to date");
}

Returns true when the repo was freshly cloned or the target branch tip moved, false when already up to date. Throws an Error if the sync fails.

Sync strategy

  1. Resolve target branch: options.branch ?? "main"
  2. git fetch origin
  3. Compare local refs/heads/<target> with origin/<target>
  4. If already equal → return false without touching the working tree (on Windows, if HEAD is on the target and the worktree is empty, files are materialized)
  5. Otherwise → fast-forward the target tip; on failure with force: true, hard-align to the remote tip
  6. Never checkout / switch the current branch
  7. Update the working tree only if HEAD is already on the target branch; otherwise only move refs/heads/<target>

This separates “pull the target line to latest” from “switch the working checkout” (left to the caller).

Windows

On win32, clone uses git clone --no-checkout, then materializes the worktree by reading blobs and writing files with illegal path characters (* ? " < > | :) stripped from each path segment. Updates on the target branch use the same materialization instead of git reset --hard, so paths that are illegal on Windows do not abort sync.

API

gitSyncd(options?)

Options

| Option | Type | Default | Description | | -------- | --------- | --------------- | --------------------------------------------------------------------------- | | cwd | string | process.cwd() | Target git repository path | | url | string | — | Remote URL. Required when cwd is not a git repo yet; runs git clone -b <branch> (Windows: --no-checkout + safe materialize) | | branch | string | "main" | Target branch to sync (not necessarily the current checkout) | | force | boolean | true | If the target tip cannot fast-forward, hard-align to remote. When HEAD is on the target, also update the worktree; otherwise only update the branch ref. No-op when already aligned |

Returns

Promise<boolean>true when freshly cloned, the target branch tip changed, or a Windows empty worktree was materialized.

License

MIT