How to create a gist on command line

2019-03-22 03:11发布

I am trying to create a gist from bash, and I have tried many versions scripts I could get, but none are working.

This seems like a correct one, but it does not work also.

curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists

I have a test.txt file with content I would like to create the gist, but it won't work. It says, invalid email, if I try to add -u USER or -u USER:PASS it still won't work saying "message": "Problems parsing JSON", ..

I don't know what is wrong. the documentation does not provide much except for this line:

POST /gists as you can see, I am passing the test.txt file.

2条回答
在下西门庆
2楼-- · 2019-03-22 03:51

I've just tried

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

and it worked: https://gist.github.com/mgarciaisaia/fa51238073eb2cf508aa

I don't see any problem in your command.

查看更多
祖国的老花朵
3楼-- · 2019-03-22 04:00

Have the same desire I found https://www.npmjs.com/package/gistup and fork the repository to https://github.com/CrandellWS/mkg because the developer did not want to support Windows which was the operating system being used at the time. So I reworked the npm package to work on windows as well as linux and apple...

Full source is available on GitHub: https://github.com/CrandellWS/mkg

Installation is simple with npm

npm install -g mkg

Use is discribed on the npmjs package page: https://www.npmjs.com/package/gistup

Once installed simply cd to which every directory you want to make a gist from...(remeber there are no subfolders with Gists)

and run the command:

mkg

and it will open your new gist in a broswer...additionally you will be able to control it like a normal git from there... just no subfolders...

查看更多
登录 后发表回答