Intellij Idea 简明教程
Intellij Idea - Version Control
IntelliJ 支持各种版本控制系统,如 Git、Subversion、Mercurial、CVS、GitHub 和 TFS。您可以直接从 IDE 执行与版本控制相关的操作。
IntelliJ supports various version control systems like Git, Subversion, Mercurial, CVS, GitHub and TFS. You can perform version control related action from the IDE itself.
在本章中,我们将讨论 Git 和 Subversion(以下简称 SVN)。我们假设读者熟悉 Git 和 SVN 工具及其术语。
In this chapter, we will discuss Git and Subversion (hereafter referred to as SVN). We assume that the reader is familiar with Git and SVN tool and its terminology.
Git
在本节中,我们将了解如何使用 Git。
In this section, we will learn how to work with Git.
Clone
要克隆现有的 Git 仓库 −
To clone an existing Git repository −
-
Navigate to File→New→Project from Version Control→Git.
-
Enter the repository URL, Parent directory and Directory name.
-
Click on the clone button to continue.
-
Upon successful running of the above steps, the repository will get cloned.
Track changes
Git 将跟踪你在仓库中所做的更改。让我们修改仓库中的任何文件,并将其与仓库进行比较。
Git will track the changes that you make in repository. Let us modify any file from the repository and compare it with the repository.
-
Navigate to VCS → Git → Compare with Latest Repository Version.
-
The above step will open the diff window.
-
You can see there is a new line on the right side with green background colour.
-
Git shows it in green as we have added new contents. If we remove any contents then it’ll be shown in red colour
Revert local changes
按照以下步骤放弃本地更改 −
Follow these steps to discard the local changes −
-
Navigate to the VCS → Git → Revert option.
-
It will ask for confirmation and remove your changes.
Add file to repository
要将文件添加到仓库,请导航至 VCS → Git → Add option 。此操作类似于 git add 操作。
To add file to repository navigate to VCS → Git → Add option. This action is similar to the git add action.
Commit changes
提交操作将创建本地提交。它类似于 git commit 操作。要执行提交 −
The Commit operation will create local commit. It is similar to the git commit action. To perform commit −
-
Navigate to the VCS → Git → Commit File option.
-
Select files to be committed.
-
Enter commit message and click on Commit button.
Push changes to the remote repository
推送操作会将本地更改发送至远程存储库。要推送更改 −
The Push action will send local changes to the remote repository. To push changes −
-
Navigate to the VCS → Git → Push option.
-
A window will appear. Here, you can see the comitts to be pushed.
-
Verify commit and click on the Push button to publish your changes.
View history or logs
要显示历史记录,请导航至 VCS → Git → Show history option 。此操作类似于 git log 命令。它将按如下所示显示历史记录 −
To show history, navigate to the VCS → Git → Show history option. This action is similar to the git log command. It will show history as follows −
Subversion
在本节中,我们将了解 Subversion 在 IntelliJ 中的工作原理。让我们考虑几个重要的操作来理解这一点。
In this section, we will understand how Subversion works in IntelliJ. Let us consider a few important actions to understand this.
Checkout
签出 SVN 存储库 −
To checkout SVN repository −
-
Navigate to File → New → Project from Version Control → Subversion.
-
Enter repository URL.
-
Click on the OK button.
Track changes
SVN 将跟踪您在存储库中所做的更改。让我们修改存储库中的任何文件,并将其与存储库进行比较 −
SVN will track changes you made in the repository. Let us modify any file from repository and compare it with repository −
-
Navigate to VCS→Subversion→Compare with Latest Repository Version
-
You can see there is new line on right side with green background colour.
-
SVN shows it in with green background to indicated the addition of new content. If we remove any content then it will be shown in red colour.
Revert local changes
按照以下步骤还原您所做的本地更改 −
Follow these steps to revert the local changes you have made −
-
Navigate to the VCS → Subversion → Revert option.
-
It will ask for confirmation and remove your changes.
Commit changes to remote repository
按照以下步骤提交远程仓库中的更改 −
Follow these steps to commit changes in the remote repository −
-
Navigate to VCS → Subversion → Commit Files option.
-
A new window will appear. Here, you can see the files to be committed to remote respository.
-
Verify the files and click on the Commit button to publish your changes.
View history or logs
若要显示历史记录,请导航至 VCS → Subverion → Show history 选项。此选项类似于 svn log 命令。它将按以下方式显示历史记录 −
To show history, navigate to the VCS → Subverion → Show history option. This option is similar to the svn log command. It will show history as follows −