1

How can I create a new remote repository from the PowerShell cmd line?

I can make a local repository from PS and I can make a remote repository from the desktop app or the web page, so how can I make a remote repository to my github account from the Powershell? I can push and pull to repositories I've made from github using git commands in the PowerShell, but I can't create a new one, why?

I've searched here, SO, the github manual, elsewhere online and I am simply at a loss. So far I am following along with this tutorial. (Of note per @Rose Perrone's answer here, this is useful if you accidentally choose to create your new repository with a readme or .gitignore file git push -f origin master)

2 Answers 2

0

I am on an old 2009 win7 lappy w/version 2 of PShell (no curl cmd) and from this SO article, it looks like the answer is: it's not an option

0

How can I create a new remote repository from the PowerShell cmd line?

This cheats but gets the job done using a combination of powershell and batch:

Function New-GitHubRepo{
        <#
    .SYNOPSIS
        Creates a new remote repository in GitHub
    .DESCRIPTION
        Creates a new remote repository in GitHub
    .PARAMETER UserName
        GitHub Username
    .PARAMETER ProjectName
        Name for the new remote GitHub repository
    .EXAMPLE
       New-GitHubRepo -UserName GUser -ProjectName "MyRepo"
    .NOTES
        Author: Michael Heath
          Date: 04/27/2019
    #>
Param(
    [Parameter(Mandatory = $true)][String]$UserName,
    [Parameter(Mandatory = $true)][String]$ProjectName
)

# This works for entering password
# New output file
$OutFile = ".\ex.cmd"

# Var for Quote
$q = [char]34

# Create part of the command line with the project name
$t =  "$q{\$q @@ name\$q @@ :\$q @@ $ProjectName\$q}$q"

# Remove the space and the @@ symbols
$t = $t.replace(" @@ ", "")

# Add the curl command and the project
$t = "curl -u $UserName https://api.github.com/user/repos -d " + $t

# put contents in the ex.cmd file
"@echo off" | out-file $OutFile -Encoding ascii
$t | Out-File $OutFile -Encoding ascii -Append

# Execute the ex.cmd file - you will be prompted for your password
cmd.exe /C ".\ex.cmd"

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .