简体   繁体   English

如何将存储库直接上传到 GitHub 组织?

[英]How do I upload a repository directly to a GitHub Organization?

I am unsure whether I've followed this process correctly.我不确定我是否正确地遵循了这个过程。 I created a project repository on my IDE PyCharm, and tried to upload into a specific GitHub organization that I'm in. On Pycharm, it gives me the option of sharing the code to GitHub. I created a project repository on my IDE PyCharm, and tried to upload into a specific GitHub organization that I'm in. On Pycharm, it gives me the option of sharing the code to GitHub. When I do this, it creates a public repository in my gitHub account but not directly in the organization;当我这样做时,它会在我的 gitHub 帐户中创建一个公共存储库,但不是直接在组织中; therefore, I have to clone that one and import it separately in the organization.因此,我必须克隆那个并在组织中单独导入它。 Is this correct process or is there a way I can import it directly in the organization from my IDE?这是正确的过程还是有办法从我的 IDE 直接将其导入组织中? Do people generally create a repository and then upload/commit files separately from their IDE or am I taking the longer route?人们通常会创建一个存储库,然后与他们的 IDE 分开上传/提交文件,还是我采取更长的路线?

Any advice would be appreciated.任何意见,将不胜感激。

The easy way to do this using only the GUI/IDE:仅使用 GUI/IDE 的简单方法:

  1. Create a project in PyCharm named your-project在 PyCharm 中创建一个名为your-project

  2. Go to your GitHub organization page and click New and name the repo your-project转到您的 GitHub 组织页面并单击 New 并将 repo 命名为your-project 在此处输入图像描述

  3. In PyCharm, under the "Git" menu click "Manage Remotes" instead of clicking "GitHub"在 PyCharm 中,在“Git”菜单下单击“管理遥控器”而不是单击“GitHub” 在此处输入图像描述

  4. In the popup, click "+" and add https://github.com/organization/your-project.git在弹出窗口中,单击“+”并添加https://github.com/organization/your-project.git

The default PyCharm "push" will now upload to your GitHub organization's repo.默认的 PyCharm “推送”现在将上传到您的 GitHub 组织的存储库。

I found a workaround similar to that proposed by @Nathan, though I'm not sure it's the cleanest way (any suggestion to improve is welcome):我找到了类似于@Nathan 提出的解决方法,但我不确定这是最干净的方法(欢迎提出任何改进建议):

  1. I created a new repository on github with the same name of my local PyCharm project (let's say it's called my_pycharm_project )我在 github 上创建了一个与我的本地 PyCharm 项目同名的新存储库(假设它被称为my_pycharm_project
  2. Following this guide , from the Terminal inside PyCharm I typed:按照本指南,从 PyCharm 内的终端我输入:

$ git remote add origin https://github.com/organization/my_pycharm_project.git

  1. This works, but then when I push files from local to GitHub inside PyCharm, they are pushed into a master branch and not into the main branch这可行,但是当我将文件从本地推送到 PyCharm 内的 GitHub 时,它们被推送到master分支而不是main分支
  2. To overcome this, I then followed this answer , which basically says to: 1) change default branch from main to master (you can do this directly from GitHub) and 2) delete the main branch为了克服这个问题,我遵循了这个答案,它基本上说:1)将默认分支从主分支更改为主分支(您可以直接从 GitHub 执行此操作)和 2)删除主分支

Of course it would be cleaner to push to the main branch, but I didn't find a way to do this.当然推送到main分支会更干净,但我没有找到这样做的方法。

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

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