Creating a New Visual Studio Repo for GitHub¶
Step 1: Create a New Repository¶
Note
Be careful if you try to use copy/paste
with the git
commands! The
$
symbols in the screenshots represent to the prompts in the terminal.
They are NOT part of the commands.
Navigate to your development folder. Enter the following 3 commands to create a new project.
$ mkdir communication-log $ cd communication-log $ git init
Now that you have a directory, open Visual Studio and create a new file.
Let’s check that our project works by running it.
You can continue to use your terminal, or you can use the terminal that is part of Visual Studio. If you want to use the Visual Studio terminal, it can be found under the View tab.
Note
If your console window does not stay open long enough for you to see your code, try adding the
Console.Read()
below theWriteLine
. This is a piece of code that will keep your terminal window open so you can read what it contains.If you can read your terminal window just fine and you haven’t added anything, then ignore this tip.
Once you’ve checked this file in the terminal, let’s stage and commit it.
First, check the
status
.$ git status On branch master No commits yet. Untracked files: (use "Git add <file>..." to include in what will be committed) communication-log.sln communication-log/Program.cs communication-log/communication-log.csproj nothing added to commit but untracked files present (use "git add" to track)
The output shows us that we have three new files that have not been staged yet. Let’s
add
everything in this directory, then check thestatus
again.$ git add . $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: communication-log.sln new file: communication-log/Program.cs new file: communication-log/communication-log.csproj
The output tells us that the files are staged. Now let’s
commit
. After that, we can see a record of our progress by usinggit log
.$ git commit -m 'Started communication log.' [master (root-commit) e1c1719] Started communication log. 4 files changed, 451 insertions(+) create mode 100644 .gitignore create mode 100644 communication-log.sln create mode 100644 communication-log/Program.cs create mode 100644 communication-log/communication-log.csproj $ git log commit 679de772612099c77891d2a3fab12af8db08b651 Author: Cheryl <[email protected]> Date: Wed Apr 5 10:55:56 2017 -0500 Started communication log.
Great! We’ve got our project going locally, but we’re going to need to make it accessible for others to view. Super important, since that’s how your work will be visible for your teaching staff.
Let’s push this project up to GitHub.