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 πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

@kanamara/worktree

v0.1.6

Published

A fast and natty tool automatically manages git worktrees for multiple repositories. πŸš€ whooooosh~

Downloads

18

Readme

A fast and natty tool automatically manages git worktrees for multiple repositories. πŸš€ whooooosh~

Motto

One window, all projects!

Background

  • 😘 Do you prefer to use VS Code to start your coding? If not, you still can be benefited from it.
  • 😑 Are you annoyed with the frequent "git switch/checkout/stash/pop" during coding?
  • 😭 Do you often jump around different projects(code editor windows)?
  • πŸ€ͺ Would you like a natty gadget to help you handle these messes? Let's try it out!

Feature

  • simple command & friendly prompt
  • automatically manage worktrees(add/remove/repair)
  • support multiple repositories

Install

node version >=14.18.0 (Due to the prefix "node:" in internal modules)

npm i -g @kanamara/worktree

Quick Start

Scenario: "Single repository, multiple branches"

Step 1. To create a directory to manage multiple branches of a repository. There are two ways:

# The first way: to create a directory from a local git repository.
wt init <directory>

# e.g.
# repository path: "/path/to/repo"
wt init /path/to/repo
# The second way: to create a directory from a remote git repository.
wt clone <repository> <directory>

# e.g.
# repository url: "https://github.com/repo.git"
# directory: "/path/to/project"
wt clone https://github.com/repo.git /path/to/project

Step 2. To add a worktree

# To add a new worktree, and checkout the "dev" branch;
# If the branch "dev" doesn't exist, it will create a new one base on HEAD(current commit).
wt add dev

Scenario: "Multiple repositories, multiple branches"

Step 1. To create a directory to manage multiple branches from multiple repositories.

# Create an empty directory in the path:"/path/to/project"
wt create /path/to/project

Step 2. Link a repository to the directory

# Link a local git repository from "/path/to/repo", and name the repository as "foo"
wt link /path/to/repo foo

# Then, you will see some changes in the "wt.config.json" file.
# {
#  repos:[{
#       path:"/path/to/repo"
#       name:"foo"
#      }],
#  type:"multiple"
# }

Step 3. To add a worktree

# add a worktree for the repo "foo", and checkout the "dev" branch.
wt add --repo foo dev

Usage

1. "wt init <directory>"

To initialize a directory from local repository, which manages all git worktrees. If the directory is not a git repository, it will help you to create a new one via "git init <directory>"

  • Only for "single-repo" projects

2. "wt clone <repo-url> <directory>"

To clone a git repository to the directory and initialize it.

  • Only for "single-repo" projects

3. "wt add <branch-name>"

To add a worktree based on <branch-name>.

  • If the <branch-name> is not specified, then it gives you a prompt.
  • If the <branch-name> doesn't exist in git branches, it will create a new branch based on HEAD
  • If you want to create a worktree with a new branch based on a commit or branch, use "wt add --base <commit-hash> <branch-name>"

4. "wt rm <branch-name>"

To remove a worktree based on the <branch-name>.

  • If the <branch-name> is not specified, then it gives you a prompt.
  • If you want to remove the branch at the same time, use "wt rm -f <branch-name>".

5. "wt create <directory>"

To create an empty directory for users to parallelly develop multiple branches of multiple repositories.

  • To use "wt link" to add repositories to the directory.
  • To use --single option to create one for single repository

6. "wt link <repo-url> <repo-name>"

To add a git repository to the directory. The <repo-url> can be a directory path, and the <repo-name> will be used as the name(id) of the repository.

7. "wt unlink <repo-name>"

To remove a git repository from the current directory.

  • If the <repo-name> is not specified, then it gives you a prompt.

8. "wt update"

  • To inspect all changes related to "git branch" and "git worktree", then regenerate configuration and repair worktrees.

Kind Reminder

  • This tool will generate some folders and configuration files to help you automatically manage your worktrees, please do not change the name of these files and folders. If you accidentally changed it, use "wt update" to repair it.

  • For convenience, worktree directories inside a single-repo project are named after the <branch-name>

    project/
    β”œβ”€ <branch-name>/
    β”œβ”€ <branch-name>/
    β”œβ”€ ...
    β”œβ”€ <branch-name>/
    β”œβ”€ wt.config.json
    β”œβ”€ wt.code-workspace
  • If worktree directories are inside a multi-repos project, then it will look like this:

    project/
    β”œβ”€ <repo-name>/
          β”œβ”€ <branch-name>/
          β”œβ”€ <branch-name>/
    β”œβ”€ ...
    β”œβ”€ <repo-name>/
          β”œβ”€ <branch-name>/
          β”œβ”€ <branch-name>/
    β”œβ”€ wt.config.json
    β”œβ”€ wt.code-workspace

Future todo

  • More informative and elegant error processor
  • Description of "wt.config.json"
  • Extra features of "wt.config.json"

Welcome to contribute and raise issues

https://github.com/GongSakura/worktree