Failing to push an existing repo to a new remote on GitHub
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- git, javascript, node.js
- 领域
- devtools
调研方向
首先,使用报告中的版本和 GitHub URL 重现经过 Clone.clone、Remote.create、getBranch、checkoutBranch、Branch.setUpstream 和 remote.push 的流程。检查相关的 NodeGit remote 和 branch API 行为以及 push 结果;完成的标准是,现有 clone 的 master 在新的 GitHub repository 中可见地存在,并且所需的调用顺序已得到验证。
由索引模型根据 Issue 内容生成。
描述
System information
- node version: 18.8.0
- npm or yarn version: 8.18.0
- OS/version/architecture: MacOS 12.5.1
- Applicable nodegit version: 0.28.0-alpha.18
What I'm Trying to Do
I'm writing an application that clones a repository from one location and pushes it to another. In vanilla git, the commands would be:
git remote add copy https://github.com/org/repo.git
git push -u copy master
I've consulted a few existing closed issues, including #1261 and #463, but am still a bit confused as to why I am not getting the results I expect.
Code
const forkDefaultBranch = `master` (obtained from an incoming webhook payload from GitHub)
const copy.data.html_url = (a url to an empty GitHub repository, created from an earlier API call)
// clone the fork
const fork = await Clone.clone(context.payload.repository.html_url, forkPath, cloneOptions)
// add a remote
const remote = await Remote.create(fork, 'copy', copy.data.html_url)
// get the default branch
const defaultBranch = await fork.getBranch(forkDefaultBranch)
// checkout the branch
await fork.checkoutBranch(defaultBranch)
I've verified in my file system that the remote is properly created.
From here I've tried both setting the upstream branch:
// set the upstream
await Branch.setUpstream(defaultBranch, 'copy/' + forkDefaultBranch)
which returns the error:
[Error: cannot set upstream for branch 'master'] {
errno: -3,
errorFunction: 'Branch.setUpstream'
}
And, following #463, I've attempted to first push to the repo:
await remote.push(['refs/heads/master:refs/heads/master'], pushOptions)
which returns no errors, but does not successfully push to GitHub as I still see the quick setup screen.
The Question
What is the proper way to push an existing repository to a new, empty repo on GitHub using nodegit?
- 主要语言
- JavaScript
- 星标
- 5.8k
- 派生
- 704
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nodegit/nodegit 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 5/5 一周以上 新手友好度 25/100
相似的 Issue
-
Edit: CW+ 未关闭channels:edit check:passed
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
idean3885/claude-ops-agent#521 ·
-
forespørsel 🥰 ikoner 🖼 nytt ✨
难度 2/5 1-3 小时 新手友好度 68/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
难度 1/5 1 小时以内 新手友好度 85/100