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
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 menu:
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:
The project is created and opens in the specified window:
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 button in the toolbar of the Local Changes tab:
Next, in the Configure Ignored Files dialog box, click . 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 to select the directory in question:
If you are a macOS user, press Shift+⌘+. to show the hidden directories, in particular,
Now you can see that the ignored unversioned files disappear (if by chance they do not, click ).
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:
In the toolbar, click the 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:
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:
There is just one line. It means that we have a single branch -
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:
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, and then choose . Though there were no commits so far, push is still possible:
The push was successful:
Now open your browser and look at your repository. Now there are two branches:
As an exercise, create
Next, using the widget, switch to
master - to do that, point to the
master branch, and choose Checkout:
You see your code from the master branch. Now change and push it. Then click the Log tab and see the following picture:
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.