2013-04-27 23 views
7

Ho accidentalmente aggiunto un file a uno dei miei elenchi, ma non so come cancellarlo. Come farlo? (Cioè, come eliminare un file da un Gist, senza cancellare l'intera Gist?)Come eliminare un file da un Gist?

Quando ho modificare e fare clic sul (x) a sinistra del nome del file, allora sia il nome del file e il suo contenuto scompaiono, ma non l'editore. E quando voglio salvarlo (Update Gist), c'è un errore "I file non possono essere vuoti".

+0

Quindi, come ho capito dalle risposte di seguito, non c'è un modo GUI, ma posso trattarli come normali repository Git e push versione con file rimosso. –

risposta

2

Non ho trovato un modo attraverso la GUI.

Tuttavia, ricorda che puoi clonare un gist, rimuovere il file e inviare una nuova versione di quel Gist a GitHub, con quel file rimosso.

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://[email protected]': 
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 

Se non si desidera che il file nella cronologia (log) del Gist, reset --hard è possibile:

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://[email protected]': 
Total 0 (delta 0), reused 0 (delta 0) 
To https://gist.github.com/efd7e7774d9526484456.git 
+ d5a76f4...d7d8b19 master -> master (forced update) 
2

Gists sono repository git, quindi è possibile clonare che Gist a il tuo computer, sfoltire quel file e forzare il repo di Gist a GitHub.

È possibile trovare l'URL del clone a sinistra del proprio elenco.

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 

In questo modo tutto, compreso la vostra storia è pulito (in questo esempio il file è calli wrong_file).

+0

So che sono passati 3 anni, ma GRAZIE, questo se per la prima volta nella storia mi spaventa di fare qualcosa in git, iniziare a cercare su Google una soluzione, e risolverla entro 2 minuti invece di 10 ore e 500 pagine ! –

5

questo ha funzionato per me nell'interfaccia utente:

  • aggiornamento succo
  • eliminare il contenuto
  • cancellare il nome del file
  • clic sulla croce blu in cui il nome del file è stato

Il modulo per il file dovrebbe scomparire.

Dopodiché, salva il tuo succo.