我不小心将文件添加到我的一个Gists中,但我不知道如何删除它。怎么做? (也就是说,如何从Gist中删除文件,而不删除整个Gist?)
当我编辑并单击文件名左侧的(x)
时,文件名及其内容都会消失,但编辑器不会消失。当我想保存它(Update Gist
)时,会出现错误“文件不能为空”。
答案 0 :(得分:5)
这在UI中对我有用:
文件的表单应该会消失。
之后,保存你的要点。
答案 1 :(得分:2)
我没有找到通过GUI的方法。
但是,请记住,您可以克隆一个要点,删除该文件,并将该Gist的新版本推回GitHub,并删除该文件。
P:\git\test>git clone https://gist.github.com/efd7e7774d9526484456.git
Cloning into 'efd7e7774d9526484456'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
P:\git\test>cd efd7e7774d9526484456
P:\git\test\efd7e7774d9526484456>dir
Volume in drive P has no label.
Volume Serial Number is D866-48E1
Directory of P:\git\test\efd7e7774d9526484456
27/04/2013 16:52 <DIR> .
27/04/2013 16:52 <DIR> ..
27/04/2013 16:52 5 f1
27/04/2013 16:52 5 f2
2 File(s) 10 bytes
2 Dir(s) 43 554 910 208 bytes free
P:\git\test\efd7e7774d9526484456>git rm f2
rm 'f2'
P:\git\test\efd7e7774d9526484456>dir
Volume in drive P has no label.
Volume Serial Number is D866-48E1
Directory of P:\git\days\efd7e7774d9526484456
27/04/2013 16:52 <DIR> .
27/04/2013 16:52 <DIR> ..
27/04/2013 16:52 5 f1
1 File(s) 5 bytes
2 Dir(s) 43 555 000 320 bytes free
P:\git\test\efd7e7774d9526484456>git st
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: f2
#
P:\git\test\efd7e7774d9526484456>git commit -m "remove f2"
[master d5a76f4] remove f2
1 file changed, 1 deletion(-)
delete mode 100644 f2
P:\git\test\efd7e7774d9526484456>git push
Username for 'https://gist.github.com': VonC
Password for 'https://VonC@gist.github.com':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 218 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To https://gist.github.com/efd7e7774d9526484456.git
b93ce40..d5a76f4 master -> master
如果你不想在你的要点的历史(日志)中找到该文件,你可以 reset --hard
:
P:\git\test\days\efd7e7774d9526484456>git lg
* d5a76f4 - (HEAD, origin/master, origin/HEAD, master) remove f2 (3 minutes ago) <VonC>
* b93ce40 - (7 minutes ago) <VonC>
* d7d8b19 - (8 minutes ago) <VonC>
* 5eae4d3 - (8 minutes ago) <VonC>
P:\git\test\efd7e7774d9526484456>git reset --hard d7d8b19
HEAD is now at d7d8b19
P:\git\test\efd7e7774d9526484456>dir
Volume in drive P has no label.
Volume Serial Number is D866-48E1
Directory of P:\git\test\days\efd7e7774d9526484456
27/04/2013 16:52 <DIR> .
27/04/2013 16:52 <DIR> ..
27/04/2013 16:52 5 f1
1 File(s) 5 bytes
2 Dir(s) 43 554 832 384 bytes free
P:\git\test\efd7e7774d9526484456>git push --force
Username for 'https://gist.github.com': VonC
Password for 'https://VonC@gist.github.com':
Total 0 (delta 0), reused 0 (delta 0)
To https://gist.github.com/efd7e7774d9526484456.git
+ d5a76f4...d7d8b19 master -> master (forced update)
答案 2 :(得分:2)
Gists是git存储库,因此您可以将该gist克隆到您的计算机上,修剪该文件并强制将gist repo推回GitHub。
您可以在要点左侧找到克隆网址。
git clone https://gist.github.com/1234567.git
cd 1234567
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch wrong_file' --prune-empty --tag-name-filter cat -- --all
git push origin master --force
这样可以清除包括历史记录在内的所有内容(在本例中,文件为calles wrong_file)。
答案 3 :(得分:0)
使用身份验证令牌(OAuth):
curl -H "Authorization: token OAUTH-TOKEN" -XDELETE https://api.github.com/gists/G1ST1D
使用凭据:
curl -u user:pass -XDELETE https://api.github.com/gists/G1ST1D
有关更多详细信息,请参见: