There are a multitude of source control repositories out there but few can compete with Git and within this area, GitHub is a great choice if you want to publish your code to the cloud. Even if it’s just POC work, having it in GitHub gives you an easy-to-reach library of archive code that you’ve long forgotten about without having to remember which folder (or even which machine) you stored it on.

Point-and-click is not a bad way to get set up and you could probably find your way around this without too much guidance but learning just a few basic git commands can not only speed up your repository synchronisation, it also gives you a better idea of what’s happening. That’s particularly useful if you are moving from a TFS background and the concepts of pull, push, fetch, sync, init etc all seem too many to map with what you are familiar.

Initial Setup

  1. Create a GitHub account
  2. Pick your local source folder (where your repositories will be stored, i.e. C:\Users\ben\source\repos)
  3. Create a directory for your first repository – I like to group repositories under certain directories and then use the group name as a prefix on my repo in git hub
  4. Create a new repo in GitHub for your solution
mkdir azure
cd azure
mkdir blobstoragetransfer
cd blobstoragetransfer

New solution

  1. Inside your local repo folder, create a new project (i.e. dotnet new…/ func init … etc.) the –source-control flag will add the necessary git files
  2. Add you project to the local git repository, commit the initial changes, set the remote repository origin to that of you new repository then push to the remote origin
git add .
git commit -m "Initial Commit"
git remote add origin{accountName}/{new-repo}
git remote -v
git push --set-upstream origin master

Switching repositories

In the instance where you may have already linked your solution to another git repository, such as azure devops, and want to repoint the solution to github, the following approach can be taken.

  1. Remove the current remote origin
  2. Add your new origin
  3. Pull any options from the new remote origin (note: if there are changes you may need to force a merge between the two master branches)
  4. Set you local master branch to point to the new origin master branch (using –set-upstream-to)
  5. Push your local changes to the new origin master branch
git remote remove origin
git remote add origin{accountName}/{new-repo}
git pull
git branch --set-upstream-to=origin/master master
git merge --allow-unrelated-histories
git push


Certified Azure Developer, .Net Core/ 5, Angular, Azure DevOps & Docker. Based in Shropshire, England, UK.


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: