{"id":20450894,"url":"https://github.com/danhper/node-git-cli","last_synced_at":"2025-04-13T02:34:02.504Z","repository":{"id":17547337,"uuid":"20350128","full_name":"danhper/node-git-cli","owner":"danhper","description":"Simple CLI like git interface for Node.","archived":false,"fork":false,"pushed_at":"2018-10-23T10:40:02.000Z","size":75,"stargazers_count":16,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-15T07:27:22.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.org/package/git-cli","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danhper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-31T05:55:09.000Z","updated_at":"2023-07-21T10:55:53.000Z","dependencies_parsed_at":"2022-09-22T20:11:36.525Z","dependency_job_id":null,"html_url":"https://github.com/danhper/node-git-cli","commit_stats":null,"previous_names":["tuvistavie/node-git-cli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fnode-git-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fnode-git-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fnode-git-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fnode-git-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danhper","download_url":"https://codeload.github.com/danhper/node-git-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381796,"owners_count":21094528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:55:34.507Z","updated_at":"2025-04-13T02:34:02.474Z","avatar_url":"https://github.com/danhper.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-git-cli [![Build Status][travis-img]][travis-build] [![Coverage Status][coveralls]][coveralls-img]\n\nA simple git interface for NodeJS.\nIt is not intended to replace projects such as \n[nodegit](https://github.com/nodegit/nodegit) but \nrather to provide a light weight solution close to \nthe git command line for simple use cases.\n\n## Installation\n\nJust run\n\n```\n$ npm install git-cli\n```\n\n## Usage\n\nThe usage is pretty straightforward, here is a sample code.\n\n```coffee\nRepository = require('git-cli').Repository\nfs = require 'fs'\n\nRepository.clone 'https://github.com/danhper/node-git-cli.git', 'git-cli', (err, repo) -\u003e\n  repo.log (err, logs) -\u003e\n    console.log logs[0].subject\n    repo.showRemote 'origin', (err, remote) -\u003e\n      console.log remote.fetchUrl\n\n      fs.writeFileSync \"#{repo.workingDir()}/newFile\", 'foobar'\n      repo.status (err, status) -\u003e\n        console.log status[0].path\n        console.log status[0].tracked\n\n        repo.add (err) -\u003e\n          repo.status (err, status) -\u003e\n            console.log status[0].path\n            console.log status[0].tracked\n\n            repo.commit 'added newFile', (err) -\u003e\n              repo.log (err, logs) -\u003e\n                console.log logs[0].subject\n\n              repo.push (err) -\u003e\n                console.log 'pushed to remote'\n```\n\nFrom version 0.10, all functions still take a callback, but also return promises,\nso you can rewrite the above as follow:\n\n```javascript\nconst Repository = require('git-cli').Repository\nconst fs = require('fs')\n\nRepository.clone('https://github.com/danhper/node-git-cli.git', 'git-cli')\n  .then(repo =\u003e {\n    return repo.log()\n      .then(logs =\u003e {\n        console.log(logs[0].subject)\n        return repo.showRemote('origin')\n    }).then(remote =\u003e {\n        console.log(remote.fetchUrl)\n        fs.writeFileSync(\"#{repo.workingDir()}/newFile\", 'foobar')\n        return repo.status()\n    }).then(status =\u003e {\n        console.log(status[0].path)\n        console.log(status[0].tracked)\n        return repo.add()\n    }).then(() =\u003e repo.status())\n      .then(status =\u003e {\n        console.log status[0].path\n        console.log status[0].tracked\n        return repo.commit('added newFile')\n    }).then(() =\u003e repo.log())\n      .then(logs =\u003e {\n        console.log(logs[0].subject)\n        return repo.push()\n    }).then(() =\u003e console.log('pushed' to remote))\n  }).catch(e =\u003e console.log(e))\n```\n\nCheckout out [the tests](test/repository-test.coffee) for more examples.\n\n[travis-build]: https://travis-ci.org/danhper/node-git-cli\n[travis-img]: https://travis-ci.org/danhper/node-git-cli.svg?branch=master\n[coveralls]: https://coveralls.io/repos/danhper/node-git-cli/badge.png?branch=master\n[coveralls-img]: https://coveralls.io/r/danhper/node-git-cli?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhper%2Fnode-git-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanhper%2Fnode-git-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhper%2Fnode-git-cli/lists"}