Skip to content
Spawn commands with Git. (Self use.)
Branch: master
Clone or download
Latest commit d5c9ea0 Nov 21, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.backup chore: backup git config Nov 12, 2018
commands git reset-last-commit Nov 21, 2018
lib git request command Nov 12, 2018
misc docs: update new mac set up Jul 25, 2018
.gitignore Update by robot Sep 19, 2017 docs: tweaks Jul 21, 2018
package.json git request command Nov 12, 2018
yarn.lock git request command Nov 12, 2018


Spawn commands with Git. (Self use.)

Git Aliases

I think you muse have used Git Aliases. Here is a git alias usage sample:

git config --global status

This means that, for example, instead of typing git status, you just need to type git st. So, where does git store this alias information? you might have already guessed the answer —— ~/.gitconfig (For macOS users).

Let's open .gitconfig and figure out:

	st = status

Okay, this is how git store aliases, so is the aliases just like this? Of course not, you can also write shell here.

Shell in Git Aliases

A quick commit process would be like this:

git add .
git commit -m "commit message"

So can we merge it into a git instruction? of course we can. According to Git Documentation:

Git simply replaces the new command with whatever you alias it for. However, maybe you want to run an external command, rather than a Git subcommand. In that case, you start the command with a ! character. This is useful if you write your own tools that work with a Git repository.

So you can use git command line to config it:

git config --global alias.commitX '!sh -c " git ad; git commit -m "$*" ;"'

Or type it in the ~/.gitconfig directly:

	commitX = "!sh -c \" git ad; git commit -m \"$*\" ;\""

Node.js in Git Aliases

With the above foundation, we can write a sample quickly:

	node-scripts = "!node app.js"

Design Ideas

If I have some scripts in directories, I hope they can be mapped to git commands automatically. e.g.       => git app
kill-node.js => git kill-node

That's what this repo mainly for. besides of git commands mapping, it also provides some instructions to help you backup or setup the git configurations.

In this repo, all scripts are placed in commands/

NPM Scripts

yarn setup

Setup global git config, which includes ~/.gitconfig and ~/.gitignoreglobal:

Equivalent to:

yarn setup-git
yarn setup-gitignore

This step is often used when you kick off programming at a new computer.

yarn setup-git

Apply $repo/.backup/.gitconfig globally.

yarn setup-gitignore

Apply $repo/.backup/.gitignoreglobal globally.

yarn backup-git

Back ~/.gitconfig up to $repo/.backup/.gitconfig.

yarn backup-gitignore

Back ~/.gitignoreglobal up $repo/.backup/.gitignoreglobal.

You can’t perform that action at this time.