portablegit
v100.5.0
Published
๐ Redistribution of Git for Windows PortableGit
Downloads
447
Maintainers
Readme
PortableGit via npm
๐ Redistribution of Git for Windows's PortableGit via npm
npx -p portablegit git add --all
npx -p portablegit git commit --message "Hello world!"
npx -p portablegit bash -c "grep version package.json"
npx -p portablegit sh ./build.sh
npx -p portablegit git-bash
npx -p portablegit gitk HEAD
๐ถ Use Git for Windows via npm
๐จโ๐ป Provides bash
via Git Bash
๐พ Uses a portable installation of Git & Bash
๐ฆ Only works on Windows
๐งฐ Useful when you need a specific Git version
Installation
You can install this package using npm or your favorite npm package manager. If possible you should use the user or global Git for Windows installation instead of this package.
npm install --save-dev portablegit
โ ๏ธ It's not recommended to install this package globally! Install Git for Windows normally on your system instead. Interested in installing Git globally on more that just Windows machines? Check out Git - Installing Git.
๐ Only works on Windows x64 systems. Does not work on macOS or Linux.
โน There is no JavaScript component to this package; it's just a redistribution of the various PortableGit files and binaries.
Usage
You can use this package just as you would any other npm package that provides binaries! It's just that these binaries are Windows-specific. ๐คทโโ๏ธ
npx -p portablegit git --version
#=> git version 2.X.Y.windows.Z
Available binary commands exposed through this npm package are:
bash
: Git Bashbash.exe
. Useful for cross-platform scripting. You can run Bash scripts on Windows!sh
: Git Bashsh.exe
. Runsbash.exe
in POSIX mode.git
: The actualgit.exe
binary for Windows. See the Git website to learn more about Git.git-bash
: Launches a terminal emulator running Git Bash. Uses MinTTY.git-cmd
: Starts acmd.exe
subshell preloaded withgit.exe
and other things in$PATH
. Does not launch a new window.git-gui
: Starts the Git GUI.gitk
: Starts the GitK GUI.
You can import.meta.resolve()
or require.resolve()
anything that would normally be in the extracted PortableGit/*
folder. Here's an example:
const cat = import.meta.resolve("portablegit/usr/bin/cat.exe");
console.log(cat);
//=> 'file:///C:/Users/you/Documents/myproject/node_modules/portablegit/out/portablegit/usr/bin/cat.exe'
const cut = require.resolve("portablegit/usr/bin/cut.exe");
console.log(cut);
//=> 'C:\\Users\\you\\Documents\\myproject\\node_modules\\portablegit\\out\\portablegit\\usr\\bin\\cut.exe'
This can be useful if you need to resolve the path to a specific binary (cat.exe
, cut.exe
, etc.) that isn't exposed by default.
Development
You'll need a Windows computer to test this package locally. You can run npm run build
to make sure everything looks good locally. npm run generate
will check for a new Git for Windows PortableGit release and download it if it exists. There's a CI script that automatically runs npm run generate
every so often and will open Pull Requests for updates. Merging these PRs to main
does not automatically create a new release -- that must be done manually. Each new release automagically publishes to npm.