Source Control (9), Push Into Git Hub And DevOps

This is a series of articles related to Source Control or Version Control issues, from the stand-alone apps, such as MS SourceSafe, to Server app, such as MS TFS (Team Foundation Server), to web services such as GitHub, AWS, and MS Azure DevOps. We tried to category this series of articles as Source Control or Version Control, but this site does not have these categories, so we make the articles in Category as DevOps, 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. DevOps is complementary with 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, so I will not step by step, instead, I write any section when I feel I am ready for it, but each section will be relatively independent to become a reading unit.

Introduction

(5) and (6) in this article series discussed how to clone solutions from Git Hub and DevOps into local, this article will discuss the opposite issue, push the local solution into Git Hub and DevOps.

In this part, we assume we already have a Git Hub Account (personal or company --- Enterprise), and a DevOps (Azure) account, and we have Git installed and configured well in the local machine, and the Git Hub Client-side Desk Top is installed.

In the major parts of this article, we will discuss how to push the local repository into the server, the remote, both in client-side and server-side. 

The structure of discussion will be,

  • Introduction
  • A: Client-side
    • A - 1: Visual Studio
      • A - 1 - 1: Add to Source Control
      • A - 1 - 2: Add to Local
      • A - 1 - 3: Push to Remote
    • A - 2: Git Hub Desktop
      • A - 2 - 1: Add to Source Control
      • A - 2 - 1: Add to Source Control
  • B: Server side:
    • Git Hub
    • DevOps
  • Summary

A: Clients

ln client side, we can do the job in different ways for different client-side tools, such as,

  • GitHub Desktop
  • Visual Studio
  • Visual Studio Code 
  • other tools

Here, we only discuss using Visual Studio and GitHub Desktop which are two popular tools developers use.

A -1: Visual Studio

Visual Studio is the major tool we use for both Github and DevOps, especially for DevOps it does not have a similar tool like Github Desktop.

A - 1 - 1: Add to Source Control

When we have a project opened in Visual Studio, like this

We want to add this project to Source Control. We have several ways (4 ways mentioned here) to initiate it in Visual Studio,

1, From Menu Bar: Click File => Add to Source Control

2, From Menu Bar: Click Git => Create Git Repository

3, From Git Changes Window: Click Create Git Repository

4, From the right corner of Visual Studio: Click Add to Source Control => Git

From any approach above, we all get the Window Crate a Git Repository,

By default, it will go to the,

Git Hub --- as the graph above

We can choose either the personal account or company account, and then click Create and Push button, we will create a local repository in Git, and push it into the server Git Hub. We will discuss the details later on in local.

If we want to create a local repository in Git and push it into DevOps, then we should choose an Existing Remote like this:

DevOps

And then give the DevOps link,

Then Click Create and Push button, we will create a local repository in Git, and push it into the DevOps server.

Finally, we examine the case.

Local Only

Click the Local Only button, and then click Create Button, then we got the local Git only, we will discuss the details in the next section below,

A - 1 - 2:  Add to Local

When choosing Local Only button in Create a Git Repository window, then Click Create Button, we create a local repository and save solution into it,

Right Click solution => Git => View History,

We see a local master repository was created,

Examination the Git Changes window, we can see under locals, there is a master copy (called branch),

While under remotes, there is nothing yet,

Basically, now we create a local repository, i.e., a local source controlled by Git. We can do the check-in, check out, the source control games locally. 

A - 1 - 3: Push to Remote

Now we push the local Git copy into a remote server, either Git Hub, or DevOps, or even others. We can do it in at least three ways, such as through.

Git Changes Window

In the Git Changes window, click the Push button;

Solution

Right Click Solution => Push to Git Service.

Menu Bar

From the solution menu bar, Click Git => Push to Git Service.

All the above three ways will go to Create a Git repository window,

Then, choosing a server, either GitHub or DevOps, Click the Push button, we can push the local Git to the server. After that, examination the Git Changes window again, we will see a branch origin/master under the remotes (server),

Now, we have a local repository, master, and a remote server repository: origin/master, then we can play the game following the article Source Control (7), Git, Azure Repos, and Visual Studio (Interaction).

A -2: GitHub Desktop

For Microsoft DevOps, Microsoft Visual Studio is its default local client, while for Github, it has a local desktop version client: Github Desktop. Now we play it in this section.

A - 2 - 1: Create a New Repository

We can do that in two ways,

1, From GitHub Desktop Menu: File => New repository

2, Click Current repository => Add => Create New Repository

Either way will open a window: Create a new repository,

Choose a location for creating the repository, then Click Create repository button, we have,

Now we created a local repository. Before we Click the button Publish repository in the window, we can view the local repository by Clicking buttons: Open in Visual Studio Code,

Or Clicking buttons: Shown in Explorer,

Now, Clicking the button: Publish repository in the window, we have the Publish repository window open,

Choose the server, either Github.com or Github Enterprise, and give the repository name, description, if it is public or private, then Click Publish repository button at the bottom, then done.

Note, either publishing to the server or not, the repository will be added into the local Github repository list,

A - 2 - 2: Add local Repository into Github Desktop

We can do that in two ways,

1, From GitHub Desktop Menu: File => Add local repository,

2, Click Current repository => Add =>  Add existing Repository,

Either way will open a window: Add local repository,

If the directory does not appear to be a Git repository, then you can click the button Add repository to Create a new repository window to create a repository,

Then, you will be redirected back to Add local repository window.

Click Add repository button, you will add the repository into Github Desktop,

then, you have a chance to do the job pushing the repository to the server,

B: Server-Side

We only briefly mention server-side creating repository here:

B -1: GitHub

In Github, Click the New button,

we get a Create a new repository window,

following the instructions, we can create a repository in the server, then if we need it in local, we can follow the instruction from (5)(6), and (7).

B -2: DevOps

In DevOps, Click the New Project button,

Open the Create new project window,

Fill in the required inputs, then Create, we have a new project created,

Summary

This article discussed the ways to push the local repository into Git Hub and DevOps.

Reference

  • We do not have references for this article, because all that I have are play and write without reading any references


Similar Articles