Using GitHub without leaving PhpStorm

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:

  • 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

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.

Develop with pleasure!
– JetBrains Web IDE Team

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm, Tutorial and tagged , , , . Bookmark the permalink.

22 Responses to Using GitHub without leaving PhpStorm

  1. Ex FromTheLeft (@ExFromTheLeft) says:

    Well done are there any plans to integrate phpstorm with bitbucket?

  2. kris says:

    So tell me if you really have something to deal with performance issue.

    Like sublime text 2/3 64 bit work like a charm. phpstorm is never make me happy regarding performance.

    this is the only issue I have….

    • Mikhail Vink says:

      It’s difficult to compare performance between text editor (Sublime Text) and IDE (PhpStorm) because they are really different and you can’t get all the features IDE provides just in the text editor. All intelligent things e.g. code autocompletion, on-the-fly error checking, etc requires some time to be performed and it can affect performance, but not significantly – so PhpStorm is indeed fast.

      If you have any significant performance issues in PhpStorm please report us following this step-by-step guide: http://devnet.jetbrains.com/docs/DOC-1253

      Thank you!

      • kris says:

        Mikhail ,
        You are exactly right.

        Happy to hear from you.

        I means that If I use VS/VWD (previously I used both) or Netbeans for now I never got performance issue.

        For now When I put comment I got problem that music is disturbed when I try to type in Phpstorm. I have reported it on bugreport.

        All thing is fine but I want to know that I loose my speed of typing when I use boilterplate or Twitter bootstrap.

        I means for other IDE which gave me good performance when I do any kind of work on them. In case of Phpstorm I loose my performance.

        performance means thing load slow. I never can type as fast as in Sublime text.

        even I have 8 GB ram ( I especially upgrade to use phpstorm) but I still have performance issue)..

        Thanks

        • UFUK says:

          Increasing RAM or even CPU will not help really. Bottleneck is the HDD. Replace it with a SSD and feel like flyin :)

          • Christian says:

            Indeed, bought a 250 gb SSD for $175. Best computer investment I’ve made.

          • kris says:

            Hello UFUK ,

            Don’t take me wrong but I don’t like to invest too much !. I will try to move to another PC in future when I really want something better :)

            What I means here that is on Windows people use Nushpere phped and Phpdesigner8 and it’s work fine. No performance issue. that 2 are editor.

            I run Komodo without any performance issue. I am not sure If java only make bad impression on Windows.

            I want to hear from someone who got no problem on Mac & linux when phpstorm. Maybe this is me who run windows and got performance trouble.

            I don’t know why people tell Sublime text only a editor. it’s have a lot of plugins and Feature for me. I can use xdebug to debug my PHP and build my Coffeescript and LESS css with just one click.

            so both PHPstorm and Sublime text 2 do same job with me. The problem I feel with phpstorm is not running well. yeah, your IDE is awesome but I can feel my hands run faster with things when I tried Sublime text 2.

        • UFUK says:

          The fact is: a single core P4 CPu and 2gb (with ssd) is much better than a computer with latest generation i7 quadcore, 16gb ram. (with hdd).

  3. BobRay says:

    My main PhpStorm project contains over 20 separate Git projects, each with a separate repository (both locally, and at GitHub). Is there any chance that PhpStorm will allow me to select any one of them as the current Git project and use it to interface with GitHub?

    I know I could create a PhpStorm project for each of them, but it’s not at all practical for what I’m doing.

    • Kirill Likhodedov says:

      Generally while multi-repository projects are supported (you just have to register them in Settings | Version Control), multi-repository GitHub projects are not.

      Some actions like “Open in browser” are accessible though.
      What actions do you wish to execute within this task?

  4. JC says:

    Is this supposed to work with a private install of GitHub Enterprise? Since the URL of the GitHub server is editable, I would assume so. However, trying to connect to our internal GitHub always fails to authenticate. It’s a shame, I’d really like to be able to use these additional features as they’re always there taunting me (esp. when I right click and see “Create Gist”). Thoughts?

    Keep up the great work, love your products!

    • Kirill Likhodedov says:

      GitHub Enterprise should be supported. If not, please open a request.

      Gists, however, can be created anonymously, so even with authentication issues this shouldn’t be a problem.

  5. Benjamin Michotte says:

    Good to know !

    Any chances to have a bugzilla integration for tasks ?

  6. Raymond says:

    This sounds great!

    Any chance we will see something like this for google code?

    • Mikhail Vink says:

      Having a project in Google Code you actually use one of these VCSs: Subversion, Mercurial, or Git selecting which one to use during the initial project setup. All these 3 VCSs are supported by PhpStorm and other IntelliJ IDEA-based IDEs so you can easily work with it from IDE.

  7. Pingback: Integration with an Issue Tracking System in PhpStorm | JetBrains PhpStorm Blog

Comments are closed.