Creating a Git Repo for a VS Solution

CS295N, ASP.NET Core Web Development

 

Weekly Topics 
1. Intro to Web Dev6. Entity Framework / Deploying a DB to Azure
2. Intro to MVC / Deploying to Azure7. Debugging / Veteran's Day holiday
3. MVC Architectural patterns8. Controllers
4. Bootstrap9. Razor Views / Thanksgiving holiday
5. Midterm Quiz / Unit testing with xUnit10. Razor Views (continued)

Contents

Announcements

No-show Drop Policy

LCC requires students to either come to class in person, or complete one assignment during the first week or they will be automaitcally dropped. The reason for this is to reduce the amount of financial aid fraud.

Todo this Week

Discord

I'm changing our class communication from Moodle forums to Discord channels. Join our class Discord server to get announcements and communicate with the class.

Git Repository Overview

There are two ways you can create a repository:

  1. Create a repo on your local machine and then push it up to GitHub.

  2. Create a repo on GitHub and clone it to your local machine.

We will do it the second way.

Git Clients

There are also multiple ways you can work with Git on your local machine. You can use:

We will use the command line since that's what most of you are familiar with.

Create a personal access token

If you haven't already created a GitHub Personal Access Token, then create one following these instructions: Creating a personal access token.

When you execute a git command that requires you to enter your user name and password, use the personal access token instead of your password.

A note about labs

For your lab assignments in CS295N, you will be creating a single web app. Each week you will add new features to it. You will not make separate folders for each lab assignment, you will just put the code for each lab assignment on a different branch in Git.

Creating a Repo

Cloning a Repo

That's it. You've cloned the repository

Adding a Branch with a VS Solution

Create a branch

On your local machine, use the command line for each step below.

  1. Change directories to the new repo you created by typing: cd followed by the directory name.

  2. Create a new branch by typing: git checkout -b followed by the new branch name. This will create a new branch and copy the files, including the .gitignore file, from the main branch into the new branch.

    For example: git checkout -b lab1 .

Here are some useful commands for working with branches:

Add a Visual Studio Solution

  1. Confirm that you are using the branch you want in the local repository.

  2. Create or add a solution folder to the repo.

    • If you already have a VS Solution folder, just copy it into the local repository folder.

    • If you are creating a new solution, then in Visual Studio, create a New Project and specify the repository as the directory to use. Note: Name the project (aka solution) with a name descriptive of your web site. For example: BookReviewSite.

  3. Add the new files to the repo index by typing; git add .

  4. Commit the files to the repo by typing git commit -m followed by a commit message in quotes.

  5. Push the new files you just committed to the origin (GitHub) by typing: git push

     

That's it. You can now see your new Visual Studio solution in your repo on GitHub!

 

Reference

W3 Schools Git Tutorial

Chacon, Scott and Straub, Ben. Pro Git book. 2nd Edition. Apress, 2014.

 


Creative Commons License ASP.NET Core MVC Lecture Notes by Brian Bird, 2022, is licensed under a Creative Commons Attribution 4.0 International License.