Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
32 lines (24 loc) · 1.08 KB

File metadata and controls

executable file
·
32 lines (24 loc) · 1.08 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var git = require('../'),
path = require('path');
// This example opens a certain file, `README.md`, at a particular commit,
// and prints the first 10 lines as well as some metadata.
git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) {
if (error) throw error;
repo.getCommit('eebd0ead15d62eaf0ba276da53af43bbc3ce43ab', function(error, commit) {
if (error) throw error;
commit.getTree(function(error, tree) {
if (error) throw error;
var builder = tree.builder(),
buffer = new Buffer("this is a file\n");
builder.insertBlob("/lib/baz.txt", buffer, false)
builder.write(function(error, treeId) {
if (error) throw error;
var author = git.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60);
var committer = git.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90);
repo.createCommit(null, author, committer, "message", treeId, [commit], function(error, commitId) {
console.log("New Commit:", commitId.sha());
});
});
});
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.