📌  相关文章
📜  如何通过 powershell 在 github 中创建新的存储库 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:24.206000             🧑  作者: Mango

代码示例1
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"