Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 如何在命令行上创建要点_Github_Github Api_Gist - Fatal编程技术网

Github 如何在命令行上创建要点

Github 如何在命令行上创建要点,github,github-api,gist,Github,Github Api,Gist,我正试图从bash中创建一个要点,我已经尝试了许多版本的脚本,但都没有成功 这似乎是正确的,但也不起作用 curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists 我有一个test.txt文件,其中包含我想创建要点的内容,但它不起作用。它说,无效电子邮件,如果我尝试添加-u USER或-u USER:PASS,它仍然

我正试图从bash中创建一个要点,我已经尝试了许多版本的脚本,但都没有成功

这似乎是正确的,但也不起作用

curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
我有一个
test.txt
文件,其中包含我想创建要点的内容,但它不起作用。它说,
无效电子邮件
,如果我尝试添加
-u USER
-u USER:PASS
,它仍然无法说出
“消息”:“解析JSON时出现问题”,

我不知道怎么了。除了这一行之外,没有提供太多:

POST/gists
如您所见,我正在通过test.txt文件

我刚试过

curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' -u mgarciaisaia:mypassword https://api.github.com/gists
它成功了:


我看不出您的命令有任何问题。

有我找到的相同愿望,并将存储库交给他们,因为开发人员不想支持当时使用的操作系统Windows。因此,我重新编写了npm包,使其能够在windows、linux和apple上运行

GitHub上提供了完整的源代码:

使用npm安装非常简单

npm install -g mkg
使用说明见npmjs包页:

安装后,只需将
cd
安装到您想要制作摘要的每个目录…(请记住,没有包含gist的子文件夹)

并运行以下命令:

mkg

它将在broswer中打开您的新要点…此外,您将能够像普通git一样控制它。。。只是没有子文件夹…

这个问题很老了,所以我不确定它是否仍然相关

在Ubuntu上(至少在18.04上),您可以尝试
gist
软件包,该软件包将安装
gist-paste
命令,您可以使用该命令(假设您已经拥有git帐户),如下所示:

1) 获取gist OAuth2令牌(它将使用该令牌创建一个~/.gist文件)。您只需执行一次:

$ gist-paste --login
然后,您可以发送文件,例如:

$ gist-paste your-file.txt
$ cat .emacs.d/init.el | gist-paste -t el
有很多选项:您可以发送文件类型/描述(如上面的第二个示例),删除gist,在浏览器中打开gist,等等。。。请参阅
gist-paste(1)
或尝试
gist-paste--help

如果您已经拥有gist令牌,则不需要运行
gist粘贴--login
,只需将
~/.gitconfig
oauth令牌
复制到
~/.gist
。 例如,如果您在
~/.gitconfig
中有:

[github]
    oauth-token = foobar123
只需创建一个
~/.gist
文件,其中一行包含“foobar123”

[编辑]如果您的发行版未提供软件包,则项目页面为:

我刚刚开始使用,它使事情变得非常简单:

#将字符串上载到文件

gist-f test.txt最近发布了GitHub CLI。 所以你现在可以用它来代替

只需将其安装到您的系统()

身份验证(非常简单)

登录后,您只需通过以下方式创建新的要点:

gh gist create -d "my test gist" -f some_local_file.txt  test_gist
有关更多详细信息,请使用帮助:

gh <command> <subcommand> --help
gh--help
截至,创建GIST是的功能之一

例如,在MacOS上:

brew安装
gh auth login#按照以下步骤操作。
gh gist create myfile.txt#创建一个私有gist。
更多选项可用<代码>创建--帮助
提供:

Create a new GitHub gist with given contents.

Gists can be created from one or multiple files. Alternatively, pass "-" as
file name to read from standard input.

By default, gists are private; use '--public' to make publicly listed ones.


USAGE
  gh gist create [<filename>... | -] [flags]

FLAGS
  -d, --desc string       A description for this gist
  -f, --filename string   Provide a filename to be used when reading from STDIN
  -p, --public            List the gist publicly (default: private)

INHERITED FLAGS
  --help   Show help for command

EXAMPLES
  # publish file 'hello.py' as a public gist
  $ gh gist create --public hello.py

  # create a gist with a description
  $ gh gist create hello.py -d "my Hello-World program in Python"

  # create a gist containing several files
  $ gh gist create hello.py world.py cool.txt

  # read from standard input to create a gist
  $ gh gist create -

  # create a gist from output piped from another command
  $ cat cool.txt | gh gist create

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual
使用给定内容创建新的GitHub gist。
GIST可以从一个或多个文件创建。或者,将“-”作为
从标准输入读取的文件名。
默认情况下,GIST是私有的;使用“--public”将其公开列出。
用法
创建[…|-][标志]
旗帜
-d、 --desc string此要点的说明
-f、 --文件名字符串提供从STDIN读取时要使用的文件名
-p、 --public公开列出要点(默认值:private)
继承的标志
--帮助显示命令的帮助
例子
#将文件“hello.py”发布为公共gist
$gh gist create--public hello.py
#创建带有描述的要点
$gh gist create hello.py-d“Python中的我的hello World程序”
#创建包含多个文件的要点
$gh gist创建hello.py world.py cool.txt
#阅读标准输入以创建要点
$gh创建-
#从另一个命令的输出管道创建要点
$cat cool.txt |创建
了解更多
有关命令的详细信息,请使用“gh--help”。
请阅读以下网址的手册:https://cli.github.com/manual

btw:我一直在尝试替换
test.txt
字符串文件带有变量,但在单引号内,它不起作用。你知道如何在单引号中传递变量吗?但是,我们如何使用gist file.cpp代码段呢?现在它显示“message”:“Not Found”,“documentation\u url”:“响应在2020年有效,确认在Ubuntu 16.04上工作,但我刚刚做了gist finename.txt这太神奇了!要安装它,请使用
sudo gem install gist
,然后
gist--login
,并将8位代码放入
github.com
。要编写多行代码,只需键入
gist
,然后使用
CTRL-D
在几行之后退出。或者,如果其中一行已打开或用作包管理器,请使用
nix shell-p gist
。要在包管理器上或与包管理器一起使用,请使用
nix shell-p github cli
Create a new GitHub gist with given contents.

Gists can be created from one or multiple files. Alternatively, pass "-" as
file name to read from standard input.

By default, gists are private; use '--public' to make publicly listed ones.


USAGE
  gh gist create [<filename>... | -] [flags]

FLAGS
  -d, --desc string       A description for this gist
  -f, --filename string   Provide a filename to be used when reading from STDIN
  -p, --public            List the gist publicly (default: private)

INHERITED FLAGS
  --help   Show help for command

EXAMPLES
  # publish file 'hello.py' as a public gist
  $ gh gist create --public hello.py

  # create a gist with a description
  $ gh gist create hello.py -d "my Hello-World program in Python"

  # create a gist containing several files
  $ gh gist create hello.py world.py cool.txt

  # read from standard input to create a gist
  $ gh gist create -

  # create a gist from output piped from another command
  $ cat cool.txt | gh gist create

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual