ngit-cli
v1.4.0
Published
A collection of commands to add interactivity to git in the command line.
Readme
NodeJS Git utilities
Purpose
Enhance the usage of git in the command line. In general this is achieved by providing a list of options when not giving the required arguments to git commands. The scripts in this repo do not aim to do anything that can be achieved through git aliases.
Scripts that replace git commands (such as checkout) attempt to act like superset commands, meaning that the checkout command can be used as the git equivalent. This is still not the case for all commands though.
Install
Run:
npm install -g ngit-cli
in your terminal to install the package globally. You can then use the program using the ngit-cli in the terminal. As this can be a bit verbose, it is recommended to create an alias for it, such as ngit.
You will then be able to use the ngit command similarly to git for the supported commands (see below) in any repo.
Usage
Running ngit without any arguments will display an interactive menu to select a command:
? Select a command
❯ add - Stage files interactively
checkout - Switch branches interactively
erase - Delete branches interactively
rebase - Rebase onto a branch interactively
stash - Stash changes interactively
select-branch - Copy branch names to clipboard
select-status - Copy file names to clipboardCommands
checkout
Works like checkout but prints out a selectable list if no parameters are passed.

Branches are sorted by the date of the last commit.
erase
Shows a selectable list of branches you can delete. By default, it only deletes local branches but you can pass the --all or -a flag to also delete the branch(es) in the remote. This list is a multiselect, which allows deleting multiple branches at once.

Branches are sorted by the creation date of the branch.
Flags
--allor-a: to also delete the branch in the remote.--goneor-g: to only show branches with a remote status ofGone(meaning the remote branch was deleted)
Warning: currently the script can't erase the remote branch if it has a different name than the local branch
rebase
Shows a selectable list of branches to rebase the current branch onto. The current branch is excluded from the list.
Branches are sorted by the date of the last commit.
stash
Differs from the usual git stash command as not passing any arguments will print out the modified files (git status). You can then select the files that you want to stash.

Note: Renamed/copied files cannot be selectively stashed due to git limitations. When renames are detected, you will be prompted to stash all changes instead.
Flags
-m: similar togit stash push, you can label your stash entry withngit stash -m <some-message>
add
Similar to ngit stash. Will print out a selectable list of files to stage.

select-branch
Prints out a multi-select list of branches to copy to you clipboard. This allows to select a branch and then paste it in another git command.
select-status
Similar to select-branch but with files in the working tree. Select the branches you want to copy to your clipboard and paste them in another git command.
To do
I plan on adding more commands such as:
- restore
- cherry-pick
The scripts I make here are the ones I feel I'm missing when using git through the CLI.
Contribution and feedback
Still very early days, so no contribution guide. But if you want to contribute or share some feedback, feel free to reach out via email or github;
