idea 上传项目到 GitHub

  1. 配置 Git
    Version Control -> Git 在这里配置 Git
  2. 配置 GitHub
    Version Control -> GitHub 在这里添加 GitHub 账户
  3. VCS -> Import into Version Control -> Share Project on GitHub
  4. 选择要添加到版本库中的文件(注意要忽略的文件或目录不要添加,也可以先设置好忽略,再做这一步),点击 Commit 按钮,提交到本地仓库。
  5. Push 到 GitHub,右键项目名或 VCS 菜单,在其中的 Git 菜单中找到 Push 项目,点击进行推送操作。

项目纳入 Git 管理后的颜色说明

红色:未加入;
绿色:已加入、未提交;
蓝色:已加入、已提交、有改动;
灰色:忽略;

忽略的文件

idea 中有一个插件 .gitignore 可以帮我们配置忽略的文件,在 Plugins 中查找并安装 .gitignore 插件,安装后重启 idea 。

  1. 在项目(模块)上右键 -> New -> .ignore file -> .gitignore file (Git)
  2. 在弹出窗口中,勾选 Example user template 选项
  3. 点击 Generate 完成

这时,项目的目录下会生成一个 .gitignore 文件,在该文件中定义要忽略的内容,.gitignore 文件本身也可以忽略。

.idea
*.iml
out
gen
/.gitignore
/target

如果版本库中已经存在要忽略的内容,那么即使在 .gitignore 中配置的有,也仍然会上传,需要先手动删除版本库中的对应文件。

.idea 目录

Project settings are stored in the project directory as a set of XML files under the .idea folder. This folder contains both user-specific settings that shouldn't be placed under version control and project settings that are normally shared among developers working in a team, for example, the code style configuration.

项目配置以 XML 文件的形式存储在项目的 .idea 目录中。这个目录包含不应置于版本控制之下的用户特定配置,以及通常由团队开发人员共享的项目配置,比如,代码样式配置。

.iml 文件

A module file (the .iml file) is used for keeping module configuration, including content or source roots, dependencies, framework-specific settings in facets, and so on.

模块文件(.iml文件)用于保存模块配置,包括内容或 source 根、依赖项、framework-specific 设置等。
.iml 文件中可能包含用户本地的路径,共享后可能会造成冲突。
缺少、误删 .iml 文件,只需要打开 idea 的 Maven 侧边栏,进行 Reimport 操作即可重新生成。

target 目录
maven 项目的输出目录,不需要上传。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容