Set Up Codehost (Github and Git)

There are many ways to transfer files from your localhost to remote host. Individual uploads and zipfile uploads are common, for example but they get awkward as your code gets big. In this class, we will use git commands to share code between your localhost and webhost, using github as a code host. In this exercise, you will make a practice repository and go through the motions of saving projects. Then, you will create your project repository.

Optional Reading

There is a nice git tutorial on w3schools that covers using git (the protocol, the server, and the command line tool) and github (the largest source of code in the world, currently owned by Microsoft). You may read through any or all of the tutorial, but it is not required to mark off this exercise. If you have difficulty understanding any of the git instructions, you may refer to this tutorial, ask questions, or use any resource on the internet or AI to help you understand.

Required Reading

Git is a highly popular version control system. You should get comfortable with it. It helps you keep track of all changes, including who made the change and when. It allows you to keep different versions (branches) of code, which enables you to experiment and to go back to old ideas. When you create a git repository on your local machine, a few commands on the command line allow you to switch between versions (branches) of your code, with files and subdirectories, in a way that feels sort of magical. You are even able to specify which files are affected by this magic. Git commands also allow you to synchronize your repository with repositories on other machines.

Github is not the same as git. If we wanted, we could set up a git server on our webhost and push and pull directly from it without involving github at all. We are not going to do that, but if we did, git commands would be our protocol to communicate with that git server. In this class, since we are trying to avoid having you do more admin than you must, we are happy to let github run the git server for us and be our official code host. We treat our local computer and web host as clients to sync with that code host. We do all the development on the local machine, push to the code host, and then from the web server we pull from the code host.

Each computer you are using (local host, web host, and code host) has its own git repository. The point of git commands is to synchronize these repositories as you update things. Many people find it confusing to have to enter several commands just to save code, but the whole point is to allow you to code and test and synchronize things when ready, which is extra helpful when multiple people are coding together, and also helpful when it is just you coding.

Open Up the Project Github Instructions in Another Tab

You are going to practice creating a repository for your project and making a few branches, following what we will do for the project this semester. Open up the Project Github Instructions from Canvas in another tab.

Create Your Practice Repository on Github

When using Github and Git, think of each project using the following diagram. Your code on your computer pushes and pulls from the remote repository on Github. Your webserver, where your website is deployed, pulls from the remote repository only. First, you will create your remote repository:

Your Git Setup
Create the Remote Repository

• Create an account on github.com (if needed).
• Hit the New button to make a new repo.
• Choose a name (like cs3660_demo).
• Mark the repo as "Private."
• Click "Create Repository."

Create a Personal Access Token

• Click your profile picture (top right)
• Click "Settings"
• Click "Developer Settings"
• Click "Personal Access Tokens"
• Click "classic token"
• Click "Generate new token.
• Set details and hit "Generate token."
• Copy and paste token. Save somewhere.
• Use token instead of password push and pull.

Create Fake Project Files

You are going to go through the steps of using your localhost, webhost, and codehost together using some fake project files. Unless you have some you want to use, feel free to just make a text file like "project.txt" with dummy content like the text "This is fake project part 1". You are encouraged to create multiple files and subdirectories to test those capabilities, but one file is sufficient to mark off this exercise as done.

Find Project Github Instructions and Go Through the Motions

Look through the Project Github Instructions on Canvas. They should be in Modules under Project Instructions. You will go through them with your practice repository and fake project file(s) for at least three project parts, or until you are comfortable.

Go Through the following steps once:

• Set Up Your Local Repository and Link It Up

Go Through the following steps at least three times, for three fake project parts, but instead of using the required directories (p1, p2, p3, etc.), use dummy directory names (like demo1, demo2, demo3, etc.):

• Start a New Project Part on Your Local Computer
• Prepare to Deploy a New Project Part to Your Web Host
• Deploy Again Each Time You Test (at least three times total for at least one project part)
• Recommended: Merge to Main When You are Done with a Project Part

Go Through the following steps at least once:

• Go Back and Fix an Old Project Part Safely After Moving On