RubyMine 2017.3 Help

Using Git tutorial

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

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:

rm clone git repository

The project is created and opens in the specified window:

rm openProject

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 properties button in the toolbar of the Local Changes tab:

rm ignore files

Next, in the Configure Ignored Files dialog box, click add. 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 browseButton to select the directory in question:

rm ignore files under folder

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 refresh).

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:

rm local changes

In the toolbar, click the icon commit 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:

rm commit dialog

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:

rm log tab

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:

rm git widget

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:

rm create new branch push

The push was successful:

rm push successful

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

rm git repository

As an exercise, create Branch_3.

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

rm master checkout

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

rm log tab branches

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: 4 April 2018