RubyMine 2017.2 Help

Using Git with RubyMine

What this tutorial is about

This tutorial aims to walk you step-by-step through creating a project and working with it with the help of RubyMine. Learning Git itself is out of scope of this tutorial - see Git documentation instead.

Before you start

Make sure thst the you've installed and configured git.

Checking out a project in RubyMine

Let's check out a project from the repository. You can do that in a number of ways:

  • If there is no open project, than on the Welcome Screen, click the Check out from Version Control link. See From Git.
  • If there's a project already open, then choose the following command on the VCS menu: Check out from Version Control | Git

Next, in the Clone Repository dialog box, specify the Git repository URL, parent directory, the name of the folder where your new project will be created, and then press Clone:

/help/img/idea/2017.2/rm_clone_git_repository.png

The project is created and opens in the specified window:

/help/img/idea/2017.2/rm_openProject.png

Ignoring files

You see that some files are not under version control (they are marked brown). We are not going to put them under version control - so let's ignore them. This how it's done...

First, click the /help/img/idea/2017.2/properties.gif button in the toolbar of the Local Changes tab:

/help/img/idea/2017.2/rm_ignore_files.png

Next, in the Configure Ignored Files dialog box, click /help/img/idea/2017.2/add.png. In the Ignore Unversioned Files dialog box, you have to select whether you are going to ignore the specified files, all the files under a particular folder, or all the files matching a certain mask.

Let's choose the Ignore all files under option and click /help/img/idea/2017.2/browseButton.png to select the directory in question:

/help/img/idea/2017.2/rm_ignore_files_under_folder.png

If you are a macOS user, press Shift+⌘+. to show the hidden directories, in particular, .idea.

Now you can see that the ignored unversioned files disappear (if by chance they do not, click /help/img/idea/2017.2/refresh.png).

Pushing a file to the repository

Change something in your file, say, delete an empty row. The name of the changed file immediately appears in the Local Changes tab of the Version Control tool window:

/help/img/idea/2017.2/rm_local_changes.png

In the toolbar, click the /help/img/idea/2017.2/icon_commit.png button to open the Commit Changes dialog box that shows files to be committed, commit message, before and after commit options, and differences viewer. Click the drop-down on the Commit button, and choose Commit and Push:

/help/img/idea/2017.2/rm_commit_dialog.png

The file in the Local Changes tab vanishes, which means that its local version is the same as its repository version.

How it looks in the Log tab?

Let's look in the Log tab now:

/help/img/idea/2017.2/rm_log_tab.png

There is just one line. It means that we have a single branch - master.

Creating new branches

Look at the bottom-right corner of the RubyMine's window. There is a widget that shows the current branch and the available actions:

/help/img/idea/2017.2/rm_git_widget.png

Choose the New Branch action. The dialog box Create New Branch opens. Specify there the name of the new branch (here Branch_2) and click OK.

However, this branch exists only locally - it doesn't exist in your remote repository. To add it to the remote repository, you have to push it. To do that, right-click the editor background, point to Git, and then choose Repository | Push. Though there were no commits so far, push is still possible:

/help/img/idea/2017.2/rm_create_new_branch_push.png

The push was successful:

/help/img/idea/2017.2/rm_push_successful.png

Now open your browser and look at your repository. Now there are two branches:

/help/img/idea/2017.2/rm_git_repository.png

As an exercise, create Branch_3.

Next, using the widget, switch to master - to do that, point to the master branch, and choose Checkout:

/help/img/idea/2017.2/rm_master_checkout.png

You see your code from the master branch. Now change and push it. Then click the Log tab and see the following picture:

/help/img/idea/2017.2/rm_log_tab_branches.png

Summary

Oof... congrats! Let's repeat what has been done with the help of RubyMine

  • You've checked a project out of Git.
  • You've ignored project files.
  • You've pushed a file to your repository.
  • You've created new branches.
Last modified: 21 July 2017