git-json

1.0.17 • Public • Published

Build Status

git-json

var gitjson = require('git-json')
var git = gitjson()

git.pipe(process.stdout)

git.init()
git.save('mydocument',{foo:'bar',val:2})
git.add('mydocument')
git.commit('first commit')
git.log()

your new working and staging functions

This chart summarizes the functions you will use in working vs staging.

Working Staging
save .save .add
trash .delete .remove

.log()

Produces a git log similar to git log --all --decorate

Git-json Log Image

.save(name,content)

Save content under "file" name into the working directory

.add(name)

Places "file" name into the staging index.

.delete(name)

Delete content under "file" name from the working directory

.remove(name)

Issues a Remove "file" name order into the staging index

.commit(message,opts={})

Peforms a commit with message. Optional opts, specify committer and/or author to override git-config globals.

.branch(branchname)

Create a branch with branchname. Call without arguments to get current named branch or detached state HEAD.

.checkout(branchname)

Returns the contents at the tip of branchname

.merge(branchname,opts={})

Peforms a fast forward merge. Optional opts, specify {noff:true} in the opts to prevent fast forward merges.

.ancestor(branchname)

Returns true if current branch tip is upstream of branchname

.isupstream(branchname)

Returns true if branchname is upstream of HEAD

.rebase(branchname)

Rebases current branch onto branchname.

.hash_object(item,isWrite)

Returns the sha-1 hash of item as used in this and Git. Pass an optional second argument true to specify that the object be written into the blob store.

.cat_file(sha)

Returns the blob specified by the sha-1 hash.


Other useful functions

.config(obj)

Sets the git configuration. Typical use is

git.config({user:{email:'joe@bar.com',name:'Joe Bar'}})
.branch()

Returns the list of all branches and indicates which branch you are on.

.visual()

Show a tree-based visual representation of the repository

.filehistory(name)

Returns the filehistory of name across all branches. Restrict output with an optional branchname or commit argument.

Contributions

Please contribute, as I actively monitor discussions and pull requests. Note the TODO list

TODO

Pencil Todo git remove
Pencil Todo NonFF merge with conflicts / rebase with conflicts
Pencil Todo garbage collection
Pencil Todo multiple parents preservation on merge
Pencil Todo rev-parse --verify and other revparse options

Recently added

  • NonFF merge without conflicts
  • git rebase without conflicts
  • treelib with commit hashes for visualizations

Thanks

#git on freenode. trash icon provided by http://www.aspneticons.com/ Disk icon provided by http://www.aha-soft.com

Copyright (C) 2016 David Wee

License MIT

Readme

Keywords

none

Package Sidebar

Install

npm i git-json

Weekly Downloads

1

Version

1.0.17

License

ISC

Last publish

Collaborators

  • rook2pawn