Phpstorm Gitlab

Posted : admin On 1/29/2022

Gitlab plugin (GitLab Projects) 1 file 0 forks 0 comments 0 stars misaon / FetchPairsDoctrine.php. Created Mar 21, 2018. Fetch pairs from entity object. In PhpStorm Tools Tasks & Content Configure servers. Add Server type Generic. PhpStorm: Using Xdebug for WordPress Development in Docker Docker, Infrastructure, PHP, Web, WordPress Deploy Containerized WordPress Websites with GitLab and Nginx-Proxy. Today we welcome GitLab.com to the list of supported repository services, working in much the same way as our GitHub and Bitbucket integrations. VSCode AndroidStudio IntelliJ PyCharm PhpStorm WebStorm RubyMine GoLand AppCode CLion Rider MPS. Video tutorial on the Git integration in PHPStorm. I walk you through all the need to know features that come with PHPStorm.This video is part of an article.

When you clone an existing Git repository, or put an existing project under Git version control, PhpStorm automatically detects if Git is installed on your computer. If the IDE can't locate a Git executable, it suggests downloading it.

PhpStorm supports Git from the Windows Subsystem for Linux 2 (WSL2), which is available in Windows 10 version 2004.

If Git is not installed on Windows, PhpStorm searches for Git in WSL and uses it from there. Also, PhpStorm automatically switches to Git from WSL for projects that are opened when you use the wsl$ path.

If for some reason you need to manually configure PhpStorm to use Git from WSL, in the Settings/Preferences dialog Ctrl+Alt+S go to Version Control Git, click the Browse icon in the Path to Git executable field and select Git from WSL via the wsl$ path, for example, wsl$debianusrbingit.

Check out a project from a remote host (clone)

PhpStorm allows you to check out (in Git terms clone) an existing repository and create a new project based on the data you've downloaded.

  1. From the main menu, select Git Clone, or, if no project is currently opened, click Get from VCS on the Welcome screen.

  2. In the Get from Version Control dialog, specify the URL of the remote repository you want to clone, or select one of the VCS hosting services on the left.

    If you are already logged in to the selected hosting service, completion will suggest the list of available repositories that you can clone.

  3. Click Clone. If you want to create a project based on the sources you have cloned, click Yes in the confirmation dialog. Git root mapping will be automatically set to the project root directory.

    If your project contains submodules, they will also be cloned and automatically registered as project roots.

Put an existing project under Git version control

You can create a local Git repository based on an existing project sources.

Associate the entire project with a single Git repository

  1. Open the project that you want to put under Git.

  2. Choose Enable Version Control Integration from the VCS Operations PopupAlt+` or from the main VCS menu.

  3. Choose Git as the version control system and click OK.

  4. After VCS integration is enabled, PhpStorm will ask you whether you want to share project settings files via VCS. You can choose Always Add to synchronize project settings with other repository users who work with PhpStorm.

Associate different directories within the project with different Git repositories

  1. Open the project that you want to put under Git.

  2. From the main menu, choose VCS Create Git Repository.

  3. In the dialog that opens, specify the directory where a new Git repository will be created.

    Git does not support external paths, so if you choose a directory that is outside your project root, make sure that the folder where the repository is going to be created also contains the project root.

  4. If you are creating multiple Git repositories inside the project structure, repeat the previous steps for each directory.

After you have initialized a Git repository for your project, you need to add project files to the repository.

Gitlab

Add files to the local repository

Phpstorm Github

  1. In the Commit tool window Alt+0, expand the Unversioned Files node.

  2. Select the files you want to add to Git or the entire changelist and press Ctrl+Alt+A or choose Add to VCS from the context menu.

    You can also add files to your local Git repository from the Project tool window: select the files you want to add, and press Ctrl+Alt+A or choose Git Add from the context menu.

When Git integration is enabled in your project, PhpStorm suggests adding each newly created file under Git, even if it was added from outside PhpStorm. You can change this behavior in the Settings/Preferences dialog Ctrl+Alt+S under Version Control Confirmation. If you want certain files to always remain unversioned, you can ignore them.

If you attempt to add a file that's on the .gitignore list, PhpStorm will suggest force adding it. Clicking Cancel in the confirmation dialog only cancels force adding ignored files - all other files will be added to the Git repository.

Exclude files from version control (ignore)

Sometimes you may need to leave certain files unversioned. These can be VCS administration files, artifacts of utilities, backup copies, and so on. You can ignore files through PhpStorm, and the IDE will not suggest adding them to Git and will highlight them as ignored.

You can only ignore unversioned files, that is files that you see in the Unversioned Files changelist. If a file is added to Git but not committed, you can right-click it in the Local Changes view and choose Rollback.

Git lets you list ignored file patterns in two kinds of configuration files:

  • .git/info/exclude file.
    Patterns listed in this file only apply to the local copy of the repository.

    This file is created automatically when you initialize or check out a Git repository.

  • One or more .gitignore files in the VCS root directory and its subdirectories.
    These files are checked into the repository so that the ignore patterns in them are available to the entire team. Therefore, it is a most common place to store the ignored file patterns.

    If there is no .gitignore file in the VCS root directory, you can right-click anywhere in the Project window, choose New File and type .gitignore in the New File dialog.

    To create a .gitignore file in Windows Explorer, create a file named .gitignore. and Windows will rename it automatically to .gitignore.

Add files to .gitignore or .git/info/exclude

  1. Decide what kind of Git configuration file you are going to use to ignore files. If in doubt, use .gitignore.

  2. Locate the unversioned file or folder you want to ignore in the Local Changes view or in Project tool window. File colors in these views help you identify the status of the file.

  3. Right click the selection and choose Git Add to .gitignore or Git Add to .git/info/exclude.
    File colors in these views help you identify the status of the file.

If you need to exclude files by a certain pattern, or files of a certain type, you can edit the .gitignore or .git/info/exclude file directly. See .gitignore patterns format

If you want ignored files to be also displayed in the Local Changes view, click on the toolbar and select Show Ignored Files.

Check project status

PhpStorm allows you to check the status of your local working copy compared to the repository version of the project. It uses specific colors to let you see which files have been modified, which new files have been added to the VCS, and which files are not being tracked by Git.

Open the Local Changes view.

  • The Default changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to the VCS but have not been committed yet (highlighted in green).

  • The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.

For more info on changelists, see Group changes into different changelists.

Track changes to a file in the editor

You can also track changes to a file as you modify it in the editor. All changes are highlighted with change markers that appear in the gutter next to the modified lines, and show the type of changes introduced since you last synchronized with the repository. When you commit changes to the repository, change markers disappear.

The changes you introduce to the text are color-coded:

  • line added.

  • line changed.

  • line deleted.

License

To customize the default colors for line statuses, in the Settings/Preferences dialog Ctrl+Alt+S, go to Editor Color Scheme VCS.

To disable VCS markers in the gutter, in the Settings/Preferences dialog Ctrl+Alt+S, go to Editor General and deselect the Highlight modified lines in the gutter option.

You can manage changes using a toolbar that appears when you hover the mouse cursor over a change marker and then click it. The toolbar is displayed together with a frame showing the previous contents of the modified line:

You can roll back changes by clicking and explore the differences between the current and the repository version of the current line by clicking .

Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.

Add a remote repository

If you created a Git repository based on local sources, you need to add a remote repository to be able to collaborate on your Git project, as well as to eliminate the risks of storing all of your codebase locally. You push changes to a remote repository when you need to share your work and pull data from it to integrate changes made by other contributors into your local repository version.

If you have cloned a remote Git repository, for example from GitHub, the remote is configured automatically and you do not have to specify it when you want to sync with it. The default name Git gives to the remote you've cloned from is origin.

For information on how to share project settings for different project formats, see Share project settings through VCS.

Define a remote

  1. Create an empty repository on any Git hosting, such as Bitbucket or GitHub. You can create a repository on GitHub without leaving PhpStorm: see Share a project on GitHub.

  2. Invoke the Push dialog when you are ready to push your commits by selecting Git Push from the main menu, or press Ctrl+Shift+K.

  3. If you haven't added any remotes so far, the Define remote link will appear instead of a remote name. Click it to add a remote.

  4. In the dialog that opens, specify the remote name and the URL where it will be hosted, and click OK.

Add a second remote

In some cases, you also need to add a second remote repository. This may be useful, for example, if you have cloned a repository that you do not have write access to, and you are going to push changes to your own fork of the original project. Another common scenario is that you have cloned your own repository that is somebody else's project fork, and you need to synchronize with the original project and fetch changes from it.

  1. From the main menu, choose Git Manage Remotes. The Git Remotes dialog will open.

  2. Click the Add button on the toolbar or press Alt+Insert.

  3. In the dialog that opens, specify the remote name and URL and click OK.

  • To edit a remote (for example, to change the name of the original project that you have cloned), right-click the remote branch in the Branches pane of the Git Log tool window, and select Edit Remote from the context menu.

    You can also edit a remote from the Push Dialog by clicking its name.

  • To remove a repository that is no longer valid, right-click it in the Branches pane of the Git Log tool window, and select Remove Remote from the context menu.

Learn more from this video:

Last modified: 23 March 2021
PhpstormGitlabFeaturesPhpStormTutorials

In a previous post we saw how PhpStorm handles Version Control Systems (VCS). A very popular VCS is Git, driven by the collaboration that’s possible using GitHub. In this post, we’ll explore several integrations with GitHub that are available from within your IDE:

Phpstorm activation code github
  • Create a GitHub repository
  • Clone a GitHub repo
  • Create a gist on GitHub
  • Open in browser
  • Use the GitHub issue tracker

Next to those actions, PhpStorm provides full support for the Git VCS like commit and update file/directory or an entire project, changelists, revision support and so forth. More on these features can be found in our earlier VCS overview post.

This functionality is available in IntelliJ Idea, PyCharm, WebStorm, PhpStorm, RubyMine, and AppCode.Before we start, make sure that PhpStorm knows the path to your Git executable. Refer PhpStorm web help on how to do this (“prerequisites”).

It’s also best to make sure that you have registered your GitHub account credentials or signed up for a GitHub account through PhpStorm. Doing this ensures that you don’t have to provide your GitHub account details every once in a while.

Create a GitHub repository

Whenever you want to start a new project on GitHub, there’s always a bit of a chicken-egg problem. Do you start coding and then push the initial code to GitHub? Or do you create a project on GitHub, clone it locally and then start coding? Depending on what you like for breakfast (chicken or egg), PhpStorm supports both, right from the IDE.

Once our project is ready to be published on GitHub, we can use the VCS Import into Version Control Share project on GitHub menu item to start publishing the project.

PhpStorm will then ask us to provide a repository name and description. After doing that, click the Share button.

There we go: our project is now available on GitHub and we haven’t left our IDE! From now on we can use any other command from the VCS menu as described in this post.

Clone a GitHub repo

Phpstorm Gitlab Projects

What if we want to continue working on an existing project hosted on GitHub? Typically, we would have to open a browser and navigate to the repository website to copy the URL we can clone using Git. Another approach would be memorizing the repository URL and cloning that. Why not clone a project from GitHub right from within PhpStorm?

From the VCS menu, we can use the Checkout from Version Control GitHub command. This will fetch a list of all repositories that we can access using our account and allows us to clone those into a PhpStorm project:

After clicking the Clone button, we’ll have the entire repository contents available locally and can code away. Once finished, simply use the traditional Git commands from the VCS menu.

Create a Gist on GitHub

If you’re unfamiliar with gists: they are a simple way to share snippets and pastes with others. They can be created, browsed and commented through https://gist.github.com/. Why copy/paste code from our IDE into a browser window if all it takes is a right-click?

From any file that’s opened in the IDE, we can make a selection of code, right-click and use the Create Gist… context menu. We can provide a description and optionally make the gist private or anonymous.

After you click OK, the selected code (or the entire file if no code was selected) will be uploaded as a gist to GitHub.

Open in browser

Ever wanted to see all details on the file you’re working on? Right-click a file and select Open in browser from the context menu. This will launch the default browser and open the file we’ve clicked on in GitHub. This allows us to see file history, explore branches and whatever other action we may want to do through the GitHub web interface.

Use the GitHub issue tracker

Working on a project often means working with issue tracking. And since GitHub has an issue tracker, let’s explore how that integrates with PhpStorm. To do so, there’s a small configuration step we have to take first.

From the File Settings menu, we’ll have to open the Tasks Servers pane under the current project settings and do some minor configuration: add the issue tracking server we want to use. Add a new server, enter the URL to your GitHub repository and provide the required credentials. Under the Commit Message pane, enable the Add commit message option and optionally customize the commit message that will be generated when we complete a task.

From now on, we can work with issues from GitHub and correlate source code commits with specific issues and tasks. Let’s create a new task. On the main menu, choose Tools Tasks & Contexts Go to Task or simply press Alt+Shift+N. This will open up a dialog which allows you to select an existing task to work on or create a new task.

We can now enter the task we want to work on and press Ctrl+Enter (Mac: Cmd-Enter) if the suggested task is the one we meant to be working on. After clicking OK this dialog will close and PhpStorm will close all files currently opened and create a new context for the work we’re going to do. On a side note, if we wanted to have more details on the task we’ve just selected we can use the Tools Tasks & Contexts Open task in browser menu or press Alt+Shift+B. This opens up a browser window with the issue logged on GitHub if you require additional information.

After making some changes, we first have to make sure PhpStorm captures all changes made to our project in a changelist. Use the Tools Tasks & Contexts Create Changelist… menu to do so. A changelist is a set of changes in files that represents a logical change in source code. The changes specified in a changelist are not stored in the repository until committed (pushed).

We can now work on other tasks and create changelists for them. Once we feel our code is good to be stored in the VCS again, we can use the VCS Commit Changes… menu or Ctrl+K (Mac: Cmd-K) to commit changes to the repository. Note that the commit message is automatically generated based on the issue we were working on:

When working with PhpStorm, a lot of GitHub functionality is integrated in the IDE. We’ve done a couple of tasks that are normally performed either on the command-line or through the browser, right from the IDE. This integration will help you be more productive because there’s less context-switching occurring.

Phpstorm Gitlab Merge Request

Develop with pleasure!
– JetBrains Web IDE Team