简体   繁体   English

我应该如何将我的 intelliJ 项目添加到已经存在的 Github 存储库中?

[英]How should I add my intelliJ project to an already existing Github repository?

I already have a Github repository, but I need to add my actual project to the repository.我已经有一个 Github 存储库,但我需要将我的实际项目添加到存储库中。 How should I do this with IntelliJ?我应该如何用 IntelliJ 做到这一点? The project should be versioned of course.该项目当然应该进行版本控制。

IntelliJ will automatically discover and "add" your git repository as soon as it finds a .git directory in the project root directory.一旦在项目根目录中找到.git目录,IntelliJ 就会自动发现并“添加”您的 git 存储库。 The steps you have to run depend on whether you already have a Git repository initialized for your project or not.您必须运行的步骤取决于您是否已经为您的项目初始化了 Git 存储库。 If not, first open a terminal (eg by pressing ALT+F12 for opening a terminal window in IntelliJ) and run如果没有,首先打开一个终端(例如通过按 ALT+F12 在 IntelliJ 中打开一个终端窗口)并运行

git init

Afterwards (or if you already have a git repository in your project) you can "connect" this repository to your project on Github with之后(或者如果您的项目中已经有一个 git 存储库)您可以将此存储库“连接”到您在 Github 上的项目

git remote add origin GIT_URL_ON_GITHUB

IntelliJ will then "find" your repository and offer git support.然后 IntelliJ 将“找到”您的存储库并提供 git 支持。

I don't know how familiar you are with IDEA hotkeys, therefore the instruction using top navigation bar: VCS -> Enable Version Control Integration -> Select your version control system (Git in your case) -> Wait for IDEA to update project -> Your project hierarchy now shows all files in brown color -> Select the files you want to commit -> Right click and select Git-Add -> In the bottom navigation bar you should also see "9: Version Control" -> Click on this button -> The window with uncommited changes appears and recently added files are green-colored -> Select the files you want to commit -> Right click on the files -> Select "Commit Changes" from the popup menu -> Specify commit message -> Hover over the "Commit" button -> Press "Commit and Push" -> In the dialog you can specify the master branch of your origin repo on Github -> Press Push after that -> You're done .我不知道您对 IDEA 热键有多熟悉,因此使用顶部导航栏的说明: VCS -> Enable Version Control Integration -> Select your version control system (Git in your case) -> Wait for IDEA to update project -> Your project hierarchy now shows all files in brown color -> Select the files you want to commit -> Right click and select Git-Add -> In the bottom navigation bar you should also see "9: Version Control" -> Click on this button -> The window with uncommited changes appears and recently added files are green-colored -> Select the files you want to commit -> Right click on the files -> Select "Commit Changes" from the popup menu -> Specify commit message -> Hover over the "Commit" button -> Press "Commit and Push" -> In the dialog you can specify the master branch of your origin repo on Github -> Press Push after that -> You're done

Feel free to ask if I missed smth.随意问我是否错过了某些东西。 out.出来。

You can initialize the local directory of your project as a Git repository with the following steps: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/您可以通过以下步骤将项目的本地目录初始化为 Git 存储库: https : //help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

Then, if you have Git plugin for IntelliJ, go to version controll, commit changes, and then you can push.然后,如果您有 IntelliJ 的 Git 插件,请转到版本控制,提交更改,然后您就可以推送了。

VCS -> Git -> Remotes...这是它的样子

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

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