简体   繁体   English

将本地分支发布到GitHub存储库

[英]Publish local branch to GitHub Repository

I'm slowly bumbling my way through learning open sourcy practices. 通过学习开放式的练习,我正在慢慢摸索自己的方式。 Currently, I'm trying to submit a pull request to a repository that's on GitHub. 目前,我正在尝试向GitHub上的存储库提交拉取请求。 I fixed a bug. 我修复了一个错误。 Now, I'd like to submit it. 现在,我想提交它。

Before I began working on the bug, I created a branch. 在开始研究该错误之前,我创建了一个分支。 That branch is called bug-fix/xyz . 该分支称为bug-fix/xyz I made my code changes. 我更改了代码。 I then ran git commit -m "Fixing bug #xyz" from the command line. 然后,我git commit -m "Fixing bug #xyz"运行git commit -m "Fixing bug #xyz" This commited the change to my branch locally. 这将更改提交到我的本地分支。 However, I noticed that my branch is not listed in GitHub. 但是,我注意到我的分支未在GitHub中列出。 From my understanding, this means that I have not "published" the branch. 据我了解,这意味着我还没有“发布”分支。 In other words, the branch only exists locally. 换句话说,分支仅在本地存在。

When I run git branch from the command-line, I see: 当我从命令行运行git branch ,我看到:

* bug-fix/xyz
  master

The first line is listed in green. 第一行以绿色列出。 How do I push/publish this branch up to the remote repository on GitHub? 如何将该分支推送/发布到GitHub上的远程存储库? I tried 我试过了

git push [repositoryName] bug-fix/xyz

However, I received an error that says: 但是,我收到一条错误消息:

fatal: '[repositoryName]' does not appear to be a git repository.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Does the repository need to be a fully-qualified url? 存储库是否需要是完全限定的网址? I can't figure out a) If I'm entering an invalid value and its something else or b) If some fully qualified url is needed since its GitHub. 我无法弄清楚a)如果我输入的是一个无效值及其它其他内容,或者b)如果自GitHub以来需要一些完全限定的url。 How do I find this value? 如何找到该值?

Thank you! 谢谢!

Type: 类型:

git config -l | grep remote

You should see something like this: 您应该会看到以下内容:

remote.origin.url=ssh://myremoteserver.git

It indicates that the origin remote is pointing to ssh://myremoteserver.git 它指示源远程指向ssh://myremoteserver.git

If it's not, you can add the remote server typing: 如果不是,您可以输入以下内容添加远程服务器:

git remote add origin ssh://myremoteserver.git

The origin can be any name you want, but there's some convention to use origin as the main remote repo. origin可以是您想要的任何名称,但是有一些约定可以将origin用作主要的远程仓库。

Having the origin pointing to the right remote repo, you just need to do 让原点指向正确的远程仓库,您只需要做

git push origin bug-fix/xyz

Done, this should work. 完成,这应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM