How to delete a file from Gist?

I accidentally added a file to one of my Histists, but I do not know how to delete it. How to do it? (That is, how to remove a file from Gist without deleting the entire Gist? )

When I edit and click (x) left of the file name, both the file name and its contents disappear, but not the editor. And when I want to save it ( Update Gist ), the error "Files cannot be empty" occurs.

+7
source share
3 answers

This worked for me in the user interface:

  • Update gist
  • delete content
  • delete file name
  • click on the blue cross where the file name

The form for the file should disappear.

After that, save your text.

+5
source

I did not find the path through the GUI.

However, remember that you can clone gist, delete the file, and push the new version of this Gist back to GitHub with the removal of this file.

 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 

If you do not want this file in the history (log) of your entity, you can 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
source

Gists are git repositories, so you can clone this gist to your computer, trim this file, and force the gist repository to be dragged back to GitHub.

You find your clone url to the left of your entities.

 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 

Thus, everything, including your story, is cleared (in this example, the file is calles wrong_file).

+2
source

All Articles