Version Control Systems Support: Basic Concepts
Modern web development workflow can hardly be effective without a Version Control System (VCS) managing all your source code. It’s absolutely essential for team development or when your project grows large. VCS takes care of all your source code management, tracking changes made by developers and letting you: revert files to the previous revision; review code before applying changes and distributing it among the whole team; correct mistakes; develop in different branches; and do lots of other useful things.
PhpStorm (and other IDEs based on the IntelliJ Platform) provides integration with several Version Control Systems, including Git, Subversion, Mercurial and others. Integration includes both support for features specific for each VCS as well as a unified interface and management for common VCS tasks.
A version control system is assigned to a project directory and/or additional directories that are part of or related to the project. In PhpStorm, you can easily clone a project from VCS and start working on it, or you can import your whole current project created locally to VCS.
Unified Version Control Functionality
PhpStorm provides a unified mechanism for working with Version Control Systems. However, some of them have unique features implemented which can simplify and speed up your work with that specific VCS.
For projects with VCS support enabled, the standard VCS actions (commit, update, revert, show differences and show history) are added to the main toolbar.
Most VCS-related functionality can be invoked from the VCS menu:
There are also a few hotkeys you’ll definitely find useful with version control systems. These include:
- Alt+BackQuote (`) / Ctrl-V to invoke VCS quick popup,
- Ctrl+K / Cmd-K to Commit project to VCS,
- Ctrl+T / Cmd-T to Update project from VCS, and
- Alt+Shift+C to View recent changes.
The following unified features are available for all VCSs:
- Commit and update file/directory or an entire project,
- Changelists support,
- Next, Previous, Rollback, and Show Difference actions are available from the dedicated gutter bar in changed locations,
- View revision history for file/directory,
- Configuration of common version control system settings,
- Advanced Version Control tool window, with multiple dedicated tabs: History, Status, Update Info, etc.
Please keep in mind that terminology differs among version control systems. For example, to share your work with others, you need to send your changes (or commits) to the remote repository. In Git you have to commit and then push while in Subversion it is enough to commit.
A changelist is a set of changes in files that represents a change in the source code. The changes specified in a changelist are not stored in the repository until committed (pushed). Any changes made to the source files are automatically included in the active changelist. Initially, the Default changelist is active, but you can make any other changelist active.
In addition to the Default changelist, you can create new changelists, delete existing ones (except for the Default changelist), and move files between different changelists.
All modified, deleted, unversioned and other files are managed in the Changes tool window.
From this window you can:
- Commit or push changelists,
- Create new changelists,
- Remove existing changelists and set the default changelists,
- Revert modified files in changelists,
- Add the unversioned files and directories to the VCS,
- Move files between changelists,
- Show differences on selected files,
- Refresh the list of VCS changes,
- Jump to the source code,
- Shelve (stash) and unshelve (unstash) changes.
For Git a Log Tab is enabled. This tab shows the changes committed in all the branches of the local and remote repositories, or in a specific local or remote branch. You also can see branch graph on the left.
For other VCSs there is the Repository tab which shows the changes committed to the repository under the VCS roots within the current project. The Incoming tab (not available for Git and Mercurial) shows the changes committed to the repository by other team members, and not yet checked out locally. Both tabs display information stored in the history cache.
You can easily check differences between files (local vs repository, file versions in different branches or in different commits) and apply actions (if you are comparing with local file) to get the proper file as a result with all the changes applied.
Shelves, Stashes and Patches
Sometimes you need to urgently switch to a high-priority task, while some other task is not complete enough to be committed. In this case you might want to put some changes aside and continue working on a stable version.
Shelving is temporarily storing not yet committed changes in a dedicated shelf. Unshelving is returning postponed changes from a shelf to a pending changelist. You can shelve and unshelve both separate files and entire changelists or shelves.
For Git, stashing and unstashing actions are supported in addition to shelving and unshelving. These features have much in common; the major difference is in the way patches are generated and applied. Shelve can operate with either individual files or bunch of files, while Stash can only operate with a whole bunch of changed files at once. Here are some more details on the differences between them.
PhpStorm helps you create and apply patches to the source code. A patch is a file in the standard text format that has the *.patch extension and contains a list of differences between the two sets of source files. You can send it to your collaborators for code review or some other purpose, in case you don’t want to commit it directly to the VCS.
In addition to the VCS there is Local History feature tracking all the changes locally. See this post in order to get more information about it.
Using a unified interface for integrated version control systems, you will easily commit, push and perform any other actions in VCS you currently work with right from the IDE. If you don’t use a VCS yet, give it a try. It will keep your source code safe and clean and help your team work more productively.
Develop with pleasure!
– JetBrains Web IDE Team
Working with Windows Azure SQL Database in PhpStorm
PhpStorm provides us the possibility to connect to Windows Azure SQL Database right from within the IDE. In this post, we’ll explore several options that are available for working with Windows Azure SQL Database (or database systems like SQL Server, MySQL, PostgreSQL or Oracle, for that matter): …
Change signature refactoring in PhpStorm
A very powerful refactoring is the Change signature refactoring in PhpStorm. It enables us to modify a function signature in many ways: we can change the function name, change its visibility, add, remove and reorder parameters as well as rename parameters. (more…)…
Folding for imports in PhpStorm 6.0
In PhpStorm 6, we've introduced code folding for imports. Any list of imports will now be folded into a single line. This greatly reduced clutter in your editor when having a lot of imports! (more…)…
Drag & Drop Project Files to Remote Hosts in PhpStorm
The Remote Host pane allows us to work directly on a remote server through FTP, FTPS, SFTP or a local/network folder. A lot of people asked us to add drag & drop to the Remote Host pane in PhpStorm. Good news: PhpStorm 6 comes with drag & drop as well as copy & paste support from the pro…