Title: "Error: Reference 'refs/heads/master' not found " when create commit in a empty repo · Issue #213 · nodegit/nodegit · GitHub
Open Graph Title: "Error: Reference 'refs/heads/master' not found " when create commit in a empty repo · Issue #213 · nodegit/nodegit
X Title: "Error: Reference 'refs/heads/master' not found " when create commit in a empty repo · Issue #213 · nodegit/nodegit
Description: Hi, I have init a repo with the code: git.Repo.init(resourcePath,false,function(initReporError, repo){ if (initReporError) throw initReporError; console.log("Repo init : "+repo); } Then I create commit with the code: git.Repo.open(path.r...
Open Graph Description: Hi, I have init a repo with the code: git.Repo.init(resourcePath,false,function(initReporError, repo){ if (initReporError) throw initReporError; console.log("Repo init : "+repo); } Then I create co...
X Description: Hi, I have init a repo with the code: git.Repo.init(resourcePath,false,function(initReporError, repo){ if (initReporError) throw initReporError; console.log("Repo init : "+repo); } Then I...
Opengraph URL: https://github.com/nodegit/nodegit/issues/213
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Error: Reference 'refs/heads/master' not found \" when create commit in a empty repo","articleBody":"Hi, I have init a repo with the code:\n\n```\ngit.Repo.init(resourcePath,false,function(initReporError, repo){\n if (initReporError) \n throw initReporError;\n console.log(\"Repo init : \"+repo);\n}\n```\n\nThen I create commit with the code:\n\n```\ngit.Repo.open(path.resolve(__dirname, '../.git'), function(openReporError, repo) {\n if (openReporError) throw openReporError;\n\n //add the file to the index...\n repo.openIndex(function(openIndexError, index) {\n if (openIndexError) throw openIndexError;\n\n index.read(function(readError) {\n if (readError) throw readError;\n\n index.addByPath(fileName, function(addByPathError) {\n if (addByPathError) throw addByPathError;\n\n index.write(function(writeError) {\n if (writeError) throw writeError;\n\n index.writeTree(function(writeTreeError, oid) {\n if (writeTreeError) throw writeTreeError;\n\n //get HEAD\n git.Reference.oidForName(repo, 'HEAD', function(oidForName, head) {\n if (oidForName) throw oidForName;\n\n //get latest commit (will be the parent commit)\n repo.getCommit(head, function(getCommitError, parent) {\n if (getCommitError) throw getCommitError;\n var author = git.Signature.create(\"Scott Chacon\", \"schacon@gmail.com\", 123456789, 60);\n var committer = git.Signature.create(\"Scott A Chacon\", \"scott@github.com\", 987654321, 90);\n\n //commit\n repo.createCommit('HEAD', author, committer, 'message', oid, [parent], function(error, commitId) {\n console.log(\"New Commit:\", commitId.sha());\n });\n });\n });\n });\n });\n });\n });\n });\n });\n```\n\nIt says \"Error: Reference 'refs/heads/master' not found\".\nI can run git add/git commit manually and it will create refs/heads/master. But the code cannot.\nSo what can I do for this? Thanks very much.\n","author":{"url":"https://github.com/v11985","@type":"Person","name":"v11985"},"datePublished":"2014-08-12T02:39:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/213/nodegit/issues/213"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0a1e3779-c305-62be-4f13-01eefb39831b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E204:259088:789F4B0:A233DD2:6A5E21DB |
| html-safe-nonce | 0adbc4761d938d20d14913f767ebe323ab25191b5f252c0f589ceeb98db70201 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjA0OjI1OTA4ODo3ODlGNEIwOkEyMzNERDI6NkE1RTIxREIiLCJ2aXNpdG9yX2lkIjoiODMwMDY2NDIzODU0Njc1NjA1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 28f1e99d698387047978bde3c61a70cb5b702dae0bdf92bf8d6a1c3d8e6ced29 |
| hovercard-subject-tag | issue:40019760 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodegit/nodegit/213/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49512dd726ae1b71b0901d4e7a01f57beb68574260c6e8d676bd21d196bcb7f5/nodegit/nodegit/issues/213 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49512dd726ae1b71b0901d4e7a01f57beb68574260c6e8d676bd21d196bcb7f5/nodegit/nodegit/issues/213 |
| og:image:alt | Hi, I have init a repo with the code: git.Repo.init(resourcePath,false,function(initReporError, repo){ if (initReporError) throw initReporError; console.log("Repo init : "+repo); } Then I create co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | v11985 |
| hostname | github.com |
| expected-hostname | github.com |
| None | e5010f4d2748a3cbef86e1580413ff14701bd99f255268dfb4a2857c77e2cc7c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git |
| octolytics-dimension-user_id | 657068 |
| octolytics-dimension-user_login | nodegit |
| octolytics-dimension-repository_id | 1383170 |
| octolytics-dimension-repository_nwo | nodegit/nodegit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1383170 |
| octolytics-dimension-repository_network_root_nwo | nodegit/nodegit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d23604c4a8ce0274b4c71bb2adbe6e1c9d5904f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width