Tips & Tricks

GitHub right in your IDE

Collaborative coding and versioning are essential for software projects. Like many others JetBrains IDEs AppCode supports a variety of Version Control Systems including Mercurial, CVS, Git, Subversion and TFS. Actions that users are provided with in various VCS tools are integrated directly into the IDE environment and look unified regardless of exact versioning system used. A helpful webinar to start with VCS in any IntelliJ-based IDE can be found on our YouTube channel or you can read an earlier overview post.
Here we would like to share some recipes and hints for one particular system – GitHub that is one of the most popular choices in the community among all platforms for hosting Git repositories. Especially often it becomes a dock for open source ships. Like CocoaPods for example.
Available in products

Start a project
To work with GitHub first specify your credentials in Preferences | Version Control | GitHub. Now you can create a new repository for your code easily:
AppCode knows if you are able to create private repositories depending on the type of your account:
You can start your development in another way, by checking out an existing project from GitHub. Browse through all your GitHub repositories from the IDE menu and pick one to clone:
After that you will be able to perform all the standard actions like commit, browse changes and history, prepare patches or postpone commits to the shelves, create change lists, annotate the code base to investigate who and when made a change in a particular code line and so on.

Once you’ve forked someone’s repository you may want to stay up to date with the origin project. For this rebase your own fork into the origin in several clicks from the AppCode IDE: select VCS | Git | Rebase my GitHub fork. You can see the status update in the Event Log, or in the status balloon that pops up:

Pull requests
Creating pull requests is a nice way to share your code with the community and to follow the collaborative development. With it you can tell others about the changes you’ve made and ask for the comments, review or just share the knowledge. With all this going on pull request will appear in the original repository only after approvement.
To prepare a pull request you don’t need to switch to the browser – you can do it right from the IDE itself, just select VCS | Git | Create Pull Request, point target branch, give some title to your request and add a description for more convenient usage:
You can Show Diff for all the changes that will be included in the request or browse the Log in the adjacent tab to learn more about commit list:

Issues tracker
When working on a project you may want to collaborate with others on the issues (be it bugs or features) and also track them for yourself in some convenient way. GitHub suggests nice and elegant solution integrated into its interface. We also support the idea and have GitHub issue tracker integrated into AppCode!
To start with any kind of the issue tracker (not only GitHub one) you should configure the preferable task server in Tools | Tasks & Contexts | Configure Servers first. There you can select from a bunch of issue trackers available:
And then fill the the server credentials including repository and commit message format. After that you can start working with the GitHub issues. You can create local tasks or select from the existing set (including both: local and remote) go to Tools |  Tasks & Contexts | Open Task (or just press Alt+Shift+N). You can include closed task to the selection and see issue description and comments with F1 key:
Start typing and you’ll see the matching issues or a suggestion to create a new task. You can create a branch for your task and also a changelist to separate the work done over this particular issue from the other part. If “Clear current context” option is selected AppCode will close all files currently opened and create a new context for the work you are going to do right after you click OK button:
You can close active tasks from Tools |  Tasks & Contexts | Close Active Task or by Alt+Shift+W. And when you decide to commit changes (Cmd+K) commit message will be automatically generated based on the issue you are working on.

Git gists and snippets sharing from the IDE
From time to time you may want to reuse some small pretty pieces of code or text or description or whatever else and create so called snippet and share it with others. GitHub supports this idea excellently and provides you with where these code snippets can be shared, versioned, forked and used through the Git and AppCode allows you to create such gists from the IDE without switching to the browser! Just select a piece of code and call Create Gist from the context menu. You can choose whether you want to make your snippet private, or anonymous:
And even look at it in the Browser after creation:
By the way you can also open any file from your project in Browser with just selecting Open on GitHub in context menu.

And what’s your favorite GitHub action that you’d like to be integrated into the IDE to avoid unnecessary context-switching?