Tai Chi 1.5 platform: using Git in the IDEA code synchronization, collaborative multiplayer

People develop the same project, code synchronization using SVN and Git. Here only a brief introduction to use Git in the IDEA.

1, install Git

The installation process, Baidu itself.

2, IDEA enabled Git

Open the settings of IDEA (CTRL + ALT + S), find the plug-ins (Plugins) option. Search git, see if you have Git plugin installed. As shown below, if not installed, check, installation enabled.

3, equipped with Git

IDEA of the settings page, expand the Version Control (Version Control), find Git options open. Git configured path, click test whether the test was successful. If successful execution of the pop-up prompt box Git, Git is configured correctly.

4, create a local Git repository

Git properly after installation and configuration, you can create a local Git repository up. IDEA toolbar found on the VCS menu, expand, select Import into Version Control, and then select Create Git Repository, to create a Git repository, as shown below.

Select the project directory, click on the third icon button, you can quickly navigate to the current project directory. As shown below.

Once created, the toolbar at the bottom, there will be Version Control tab key, as shown below. And find a project file appear color-coded files in different versions of the state, will display different colors.

So far, Git local library to create success.

5, the installation .ignore plug

Source files require version control, you do not need a lot of file version control, we should not need to be added to the ignore list, which is no longer committed to the repository.

To ignore a lot of project files, we need one by one to the ignore list, too much trouble. Therefore, we use .ignore plug-in to help.

In the Settings page, click plug-ins (plugins), switch to the first tab Marketplace, search ignore, you can see if you have installed. If not, click install to install; if installed, you need to install.

Of course, you can also switch directly to the first two tabs installed, to see if you have installed. As shown below, .ignore installed plugins.

6. Create a file is ignored

现在使用.ignore插件来创建忽略文件。在项目上,点击右键,new,选择.ignore file忽略文件,选择子项.ignore file(Git)。如下图所示。

在弹出界面,勾选Example user template、Java、Maven,这3个选项模板,点击确定生成generate。

在项目中就会出现新建的.ignore文件,默认会打开。如下图所示,已经默认添加了很多忽略文件和文件夹。

在文件中,我们还有再额外添加几个忽略文件:overlays、.gitignore。如下图所示。

最后,我们发现没有版本控制的文件,只有3个了,如下图所示。按住Unversioned Files选项,直接拖到Default Changerlist中,将这3个文件加入到版本控制中。

7、Git提交

按CTRL+K,弹出提交界面。填写本次修改日志。

可以把下图所示的2个复选框勾选去掉,加快提交速度。一个是代码分析,一个是检查TODO,其实没这个必要。

如果远程服务器已经创建了Git库,则可以同步push到远程服务器。

8、远程服务器

可以到GitHub,或者码云gitee.com(国内)去申请一个账号,存放代码。当然,也可以自己搭建Git服务器。push的时候,配置一下远程服务器,即可将本地库同步到远程库了,从而实现多人协作。

提交成功后,在Version Control的标签页,已经可以看到日志记录。如下图所示。如果要从服务端获取代码,则使用pull菜单。

发布了89 篇原创文章 · 获赞 71 · 访问量 14万+

Guess you like

Origin blog.csdn.net/weixin_42127613/article/details/97155909