How to use PyCharm and git CLI to author PRs

PyCharm is a popular IDE that is free to all students through jetbrains. PyCharm has a built in terminal and python console that can make authoring easy!

How to setup PyCharm

After you download PyCharm, you'll need to clone the repository for Kite Answers

Cloning Repositories

Firstly, navigate inside the attached terminal at the bottom of the PyCharm window to the location you would like to save the repository at, this is commonly Documents/git.

Then run the following command git clone link with link as the target repository. In our case that would be git clone [email protected]:kite-answers/answers.git.

How to manage git from CLI

git is commonly managed with CLI, or command line interface, commands. These CLI commands can do everything that git has to offer: create branches, refresh the repository, etc.

How to refresh a branch

Whenever you return to your PyCharm instance, you should always refresh your git repository.

Use git pull to refresh a repository.

How to create a branch

Creating a branch creates a distinct library of files from the master, or default, branch for you to work on without interfering with others.

Use git checkout -b branch_name to create a new branch named branch_name.

For Kite Answers, branch names should follow the format:

-

For example: wclatimer-how-to-use-pycharm-and-git

How to checkout a branch

Checking out a branch switches which branch you are working on. It is best practice to switch branches to the master branch before creating a new branch, each time.

Use git checkout branch_name to checkout a branch.

My workflow in PyCharm

I use the following workflow to author issues

Finding Issues

I find issues by milestone. Finding issues by milestone ensure you find multiple issues when you find something you want to work on

Create a new branch

I use the following compound command to 1) switch to master, 2) refresh master, and 3) create my new branch with name branch_name.

git checkout master; git pull; git checkout -b branch_name

Create a new markdown file

Now that we're on a new, fresh branch, it's time to create our markdown file. I use PyCharm's file template system to automatically generate an outline for my new PR.

How to create a file template in PyCharm

Open the new file panel by going to File>new or by right clicking in the project panel on the left side of PyCharm. Navigate to "edit file templates" inside the new file dialog.

In the top left corner, there is a + symbol. Click this button to create a new template. Name this template whatever you would like and write md in the "Extension" box. Paste the following template into the box for code:

headers:
    use-yy: Use `yy`

---

# Title

Description and example

#/# Use [`first header`](kite-sym:something) part of title {#use-yy}

Call [`full method declaration of first header`](kite-sym:something) to do something

```python
KITE.start_prelude()
#imports
KITE.stop_prelude()

#do the thing
After pasting in this file, click "Ok" to save the file.

How to create a file using a template

Now that we've written a template file, we can create a file from this template by navigating to the same new file dialog. Go to File>new or right click in the Project panel on the left side of the PyCharm window to open the new file dialog. Inside this new file dialog, you should see the template file you created in the previous step. Click this template name and write a name for the file, without an extension.

File names should mirror the content of the PR. For example, how-to-use-pycharm-and-git.md.