将分支推送到 Git
我正在处理一个本地存储库,其远程存储库托管在 GitHub 上。 我最近创建了一个分支并开始对其进行处理,进行了多次提交,现在希望将分支推送到 GitHub 并能够将其拉到另一个克隆存储库。 我该怎么做呢?
I have a local repository I'm working on and its remote is hosted on GitHub. I recently created a branch and started working on it, making several commits and now wish to push the branch to GitHub and be able to pull it to another cloned repository. How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
替换
和
。 它们可以相同也可以不同,如您所愿。Substitute for
<local-branch-name>
and<remote-branch-name>
. They may be same or different, as you wish.由于您已经设置了遥控器,因此该命令仅
在第一次按下时发出。
之后,使用 git push origin 会将具有匹配名称的所有分支推送到远程。
As you have set up the remotes already, the command is just
on the first push.
Afterward, using
git push origin
would push all branches with the matching name on remote.确保您的远程 URL 使用 SSH 语法而不仅仅是 Git 协议语法。 如果你运行,
打印的 URL 应该看起来像这样,
如果你想能够推送,你也需要 URL 看起来像这样。 如果您只是一个公共用户(没有写入权限),则 URL 将如下所示,
如果您的 URL 看起来像后者,那么您可以在项目
.git/config
文件中手动编辑它。Make sure that your remote URL is using SSH syntax and not just Git protocol syntax. If you run,
the URL printed should look something like,
You need the URL too to look like that if you want to be able to push. If you are just a public user (without write access) the URL will look like,
If yours looks like the latter then you can manually edit it in your projects
.git/config
file.如果您需要将任何分支代码从远程拉取到本地,
而如果您需要将代码推送到分支
您需要检查您的代码是否成功保存
您可以检查
比
在此提交到您的分支之后
比(最后)
通过以下方式将代码推送到分支:
if you need to pull any branch code from remotely to locally
while if you need to push code to your branch
you need to check is your code successfully save
you can check by
than
after this make commit to your branch
than(Last)
push your code to your branch by: