You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no git add since there is no staging area. But you can save new objects to the database using repo.saveAs. So to add a new file you'll need to repo.saveAs("blob", contentAsStringOrBuffer, callback). Then then will give you the hash. To store it in a tree somewhere you update or create the tree entry where it goes and repo.saveAs("tree", treeData, callback) to get the new hash for the tree, then if it's a subfolder update that tree's entry in it's parent recursivly up to the root tree. Then once you have a new root tree you create a new callback that points to the tree and points to the old commit as it's parent. Then if you want to preserve this new commit, update the branch ref to point to it.
varentries=[{path: "foo/bar.js",mode: modes.blob,content: "console.log('Hello world');\n"},// Other updates can go in this array as well.];entries.hash=oldRootTreeHash;// This is the hash of the tree you wish to base on, inherit from.repo.createTree(entries,function(err,hash){if(err)returnhandleError(err);// You now have the new root tree hash, store it somewhere, create a new commit or whatever else you wanted to do.});
Hi,
how do you perform an add and commit ?
thanks
The text was updated successfully, but these errors were encountered: