Source Control (5-1), Create a Git Hub Repository from Visual Studio

NoteThis is a series of articles related to Source Control. If you have read my other articles in this series, you may skip the top general part and jump to INTRODUCTION for the specific topic of this article.

This is a series of articles related to Source Control or Version Control issues, from a stand-alone app, such as MS SourceSafe, to a Server app, such as MS TFS (Team Foundation Server), to web services such as GitHub, AWS, and MS Azure DevOps. We have tried to categorize this series of articles as Source Control or Version Control, but this site does not have these categories. So, we put the articles in the DevOps category, as explained in the Wiki:

DevOps is a set of practices that combines software development (Dev) and IT operations (Ops). It aims to shorten the systems development life cycle and provide continuous delivery with high software quality.[1] DevOps is complementary to Agile software development; several DevOps aspects came from the Agile methodology.

The structure of this article series will cover:

  • Stand Alone App:
    • MS Source Safe
  • Server App
    • MS TFS (Team Foundation Server)
  • Online (Cloud) Centralized Service:
    • MS Azure: DevOps
      • Boards
      • Repos
      • Pipelines
      • Test Plans
      • Artifacts
    • GitHub
    • AWS GitHub Enterprise
  • Distributed App:
    • Git

Because these are huge topics, I will not go step by step. Instead, each section will be relatively independent and will become a reading unit.

A - Introduction

In the previous article, Source Control (5), GitHub access (setup connection), we discuss the access for GitHub (and Enterprise). We mentioned:

In certain situations, we cannot see the Connect to GitHub, probably by settings, like this:

Create a Git Hub Repository from Visual Studio

instead, we have this, without "Connect to GitHub":

Create a Git Hub Repository from Visual Studio

We will discuss this situation here.

  • A - Introduction
  • B - Alternative Way to Create a New Repository in GitHub
  • C - Change Remote Origin to Create a New Repository in GitHub

B - Alternative Way to Create a New Repository in GitHub

In this situation, we can do this: Click Connect => Project and My Teams => New Repository

Create a Git Hub Repository from Visual Studio

Open the window: Create a Git repository: for GitHub

Create a Git Hub Repository from Visual Studio

Create and Push, or we can choose the Existing Remote choice

Create a Git Hub Repository from Visual Studio

C - Change Remote Origin to Create a New Repository in GitHub

In this case, the source code has been within a Remote Repository, such like:

Create a Git Hub Repository from Visual Studio

Use the method we introduced above to Create a New Repository, we got a warning message:

A local Git Repository already exists at this location. 

Create a Git Hub Repository from Visual Studio

the push button is grayed out. When we choose the existing remote:

Create a Git Hub Repository from Visual Studio

the same, the push button is grayed out.

At this point, we can go around by changing the remote origin, and make a new repository.

Change the Remote Origin

Click Settings

Create a Git Hub Repository from Visual Studio

Click Repository Settings

Create a Git Hub Repository from Visual Studio

Open the window: Options

  • Source Control
    • Git Repository Settings
      • Remotes

Create a Git Hub Repository from Visual Studio

Click origin on the right panel => Edit

Create a Git Hub Repository from Visual Studio

Change the origin to a new one:

Create a Git Hub Repository from Visual Studio

Now, if we pull from the origin or push local to remote origin

Create a Git Hub Repository from Visual Studio

We will get error message: the repository not found, for Pull

Create a Git Hub Repository from Visual Studio

for Push

Create a Git Hub Repository from Visual Studio

Create the Repository from GitHub

Click New button in GitHub

Create a Git Hub Repository from Visual Studio

Creating a New Repository

Create a Git Hub Repository from Visual Studio

A new Repository is created

Create a Git Hub Repository from Visual Studio

Then, Pull, we can see the error message said "Branch 'master' was not found in the remote repository

Create a Git Hub Repository from Visual Studio

Push, the local repository will be saved into remote.


Similar Articles