Hello, World!

This in-class activity is designed to introduce you to using git-keeper, PyCharm, and Markdown.

You should have gotten an email from git-keeper with a clone URL and a link to this activity. If this is the first time you are in one of my classes, or if you have not been in one of my classes since I last reset the git-keeper server, you should have received another email with a username and password for the server.

If you are off campus you will need to use the campus VPN in order to clone from and push to the git-keeper server. Instructions for setting up the VPN are here: https://wiki.wooster.edu/pages/viewpage.action?pageId=32836370

Git-keeper Assignments

The workflow for most git-keeper assignments will be as follows:

  1. Receive an email with a clone URL for a Git repository on the server
  2. Clone the repository using the URL from the email
  3. Do your work in the local clone of the repository
  4. Commit your changes to the local repository
  5. Push your changes back to the server
  6. Check your email to make sure the submission was received and see the results of any tests that were run.

Cloning a Git Repository with PyCharm

You can clone a Git repository using PyCharm and it will automatically make a project for you. It is also possible to do all of the Git stuff for this activity on the command line (and in fact I generally prefer that), but for this activity I would like you to see the Git workflow within PyCharm.

Open up PyCharm and follow these steps:

The project should now be open in PyCharm.

hello_world.py

There is an empty file in the project named hello_world.py. Double click this file to open it and write a program that simply prints the string 'Hello, world!'. This is a one-liner in Python:

print('Hello, world!')

To run this program, right click on hello_world.py and select “Run ‘hello_world’”. The program’s output will be in the bottom part of the screen. Once you have run a program in a project for the first time this way, you can re-run it more quickly in the future by pressing the green triangle button in the upper right toolbar.

github_username.md

There is also an empty file named github_username.md. .md is the extension for Markdown files. Markdown is a markup language. Other markup languages include HTML and Latex. Markdown is much simpler than both of those and is designed to look good both as plain text or when rendered as a web page or PDF. Markdown is used to write README files on GitHub, comments on Reddit, and many other places. The text you are reading right now was also written in Markdown.

When you open github_username.md in PyCharm there will be a two panes for the Markdown file. In the left pane you will type the plain Markdown text. In the right pane it will show you a preview of what the text will look like when rendered.

Type the following into the left pane:

# GitHub Username

Here is my GitHub username:

* <username>

Replace <username> with your actual GitHub username. Note that this is not your git-keeper username! If you did not do so already, you need to create an account at https://github.com.

Now note the contents of the right pane. A line that starts with # is a header in Markdown, so it appears as a large header. “Here is my GitHub username:” appears normally. The username itself starts with a * which means it is the first item in a bulleted list.

Using Markdown is overkill for this file, but we will use it more extensively later in the class. I have written a guide for using Markdown here. The official site has a more extensive guide here.

Committing and Pushing your Changes

Now that you have edited these two files, you can push your changes back to git-keeper. Note that in the project view on the left of the screen these two filenames are blue. That means that there are uncommitted changes to these files.

To commit the changes, go to the “VCS” menu and select “Commit”. Note that there are checkmarks beside the two files that you want to commit. If you only wanted to commit changes to a subset of files in the project, you could uncheck some of the filenames. For this activity, leave both files checked.

You will need to enter a commit message. For this activity it is not important what the message is, so enter something like “Completed activity”. Now click the drop-down button to the right of the “Commit” button and select “Commit and Push…”. On the next screen select Push.

After you push you will receive an email from git-keeper. Pushing this activity triggers some tests, and the email will contain the results of those tests.

Note that after you’ve committed, the filenames are no longer blue.