Some simple git commands should be enough to get started in this course. You should take the time to follow a git tutorial, which may be found in the resources section of the syllabus.
A usual workflow:
If you are on Windows, you should install git from https://git-scm.com. Linux and MacOS will have git installed already. From this point, you will need a terminal on whatever OS you are using. On Windows, that can be found in the start menu under the Git folder. On Linux/Mac, find your terminal application.
When you first start a project (accept a homework), you will have a repository given to you. You must clone the repository to your local computer. You can find the URL for cloning under the "Clone or download" button.
Next, you will find a directory you wish to work from in your terminal. If you are using bash or zsh, you can create directories with
mkdir <dirname> and use
cd to change directory as needed.
git clone <URL> replacing the URL given by GitHub to clone the directory.
After cloning, you will use several common commands in a cycle to do your work.
Edit files as necessary. When you are at a point where you wish to save progress, continue to step 2.
git add -uto add the files in the repository that have changed to a staging status to be committed.
git commit -m "your message here"to commit the staged changes. Use a descriptive message in case you need to go back to that work!
git statusto see that all changes to relevant files have been committed. You can do this at any point to see what is going to be committed or what has been changed since the last commit.
git push origin masterto push your changes up to GitHub and create a submission. You can do this as much as you like, and no changes will be visible on the website or to the instructor until you do this step!
Go back to step 1 until you are done
I highly recommend you learn Git from the commandline and do not use a GUI if you have not used it in the past. You will find it very hard to work with if you do not understand what the GUI is doing under the hood. Skip this experience at your own peril. I will not spend time supporting the GitHub client or other GUI methods.
Prerequisites for all platforms:
Git (only necessary to install on Windows)
.NET Core - I suggest getting the latest version from https://dotnet.microsoft.com/download
VS Code https://code.visualstudio.com
ionide-fsharp - found in the extensions section of your VS Code editor, more info here: https://marketplace.visualstudio.com/items?itemName=Ionide.Ionide-fsharp
If using Windows, you may need to install F# language support in regular Visual Studio for some code completion and F# interactive features to work. Your mileage may vary as newer versions of Core are supposed to have this functionality.
Working with F# and VS Code
Open the git directory from wherever you cloned it. If you have all of the prereqs, you should be looking at a project like mine:
The first and most important step is to open the .fsproj files and fix them. Note that we are currently looking at the F# project (the highlighted left bar has the ION IDE icon highlighted). The fsproj files are not visible here, but you can right click on the projects (Homework1 and Homework1.Tests) and edit their project files.
We need to change the
TargetFrameworkXML to match our version of .NET Core. You probably do not have 2.1 installed. Under the Terminal menu item, select "New Terminal" so that we can find out what version we have. Type
dotnet --list-sdksinto this window. You probably have 3.1 installed. I have many versions.
Change the text to match the version you have. For 3.1, that’s going to be
Repeat this change for the other fsproj file (Tests as well)
In your terminal, run
dotnet testto see that you can execute the project and the tests.
You can now edit the
Homework1/Library.fs to complete the assignment.
Remember that the F# Interactive is a good way to test code and run the samples from class. You can use
command+shift+p to pull up the command window. Type "FSI" to see the interactive commands.
Selecting any code from the editor and pressing
alt+enter (that’s option on Mac) will run the selected code in the interactive window. I suggest you code in the text file and run parts of the code interactively to see how things are working as you progress.