在Git Bash中创建远程repo时,CURL的文本替换失败

在Git Bash中创建远程repo时,CURL的文本替换失败,curl,github,directory,repository,git-bash,Curl,Github,Directory,Repository,Git Bash,我在git bash中使用CURL时遇到了一个问题: 我打算使用目录名创建一个远程存储库 但是,$folder在下面的脚本中无法正常工作,代码生成的存储库是username/-folder 请仅替换第6行和第7行中的用户名和密码以重现问题 这个问题可以通过转义引号来解决 “{\“name\”:\“$folder\”}” 这个问题可以通过转义引号来解决,“{\“name\”:“$folder\”}”我很高兴这个结果很简单。我们可能都被Git Bash或cURL的问题分散了注意力。OP和未来的读者应

我在git bash中使用CURL时遇到了一个问题:

我打算使用目录名创建一个远程存储库

但是,
$folder
在下面的脚本中无法正常工作,代码生成的存储库是username/-folder

请仅替换第6行和第7行中的用户名和密码以重现问题


这个问题可以通过转义引号来解决
“{\“name\”:\“$folder\”}”

这个问题可以通过转义引号来解决,
“{\“name\”:“$folder\”}”
我很高兴这个结果很简单。我们可能都被Git Bash或cURL的问题分散了注意力。OP和未来的读者应该注意,在Git Bash(在Windows上)中运行cURL有一些问题需要注意:
#! /usr/bin/env bash
folder=`basename "$PWD"`
git init
git add .
git commit -m 'First commit'
curl -u 'username:password' https://api.github.com/user/repos -d '{"name":"$folder"}'
git remote add origin https://github.com/username/$folder.git
git push -u origin master
$ ./script
Initialized empty Git repository in C:/Users/username/../directoryname/foldername/.git/
[master (root-commit) 20725a2] First commit
 Committer: username
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 5 files changed, 33 insertions(+)
 create mode 100644 code/bash.txt
 create mode 100644 code/fraud.bat

... A BUNCH OF MESSAGES HERE THAT SO THOUGHT WAS SPAM...

  "milestones_url": "https://api.github.com/repos/username/-folder/milestones{/number}",
  "notifications_url": "https://api.github.com/repos/username/-folder/notifications{?since,all,par100 5329  100  5311  100    18   3433     11  0:00:01  0:00:01 --:--:-- 3444ipating}",
  "labels_url": "https://api.github.com/repos/username/-folder/labels{/name}",
  "releases_url": "https://api.github.com/repos/username/-folder/releases{/id}",
  "deployments_url": "https://api.github.com/repos/username/-folder/deployments",
  "created_at": "2018-06-20T14:14:07Z",
  "updated_at": "2018-06-20T14:14:07Z",>       "ssh_url": "git@github.com:username/-folder.git",
  "clone_url": "https://github.com/username/-folder.git",
  "svn_url": "https://github.com/username/-folder",
  "allow_squash_merge": true,
  "allow_merge_commit": true,
  "pushed_at": "2018-06-20T14:14:08Z",
  "git_url": "git://github.com/username/-folder.git",
  "allow_rebase_merge": true,
  "network_count": 0,
  "subscribers_count": 0
}

remote: Repository not found.
fatal: repository 'https://github.com/username/example1.git/' not found