Foros del Web » Programando para Internet » GIT »

Como eliminar archivo temporal en GIT?

Estas en el tema de Como eliminar archivo temporal en GIT? en el foro de GIT en Foros del Web. 1-Cree un archivo nombre.docx, al crearlo tambien se creo un archivo ~nombre.docx 2-realice cambios en ese archivo 3-hice el commit y el git push 4-cerre ...
  #1 (permalink)  
Antiguo 25/02/2013, 20:57
 
Fecha de Ingreso: octubre-2006
Mensajes: 227
Antigüedad: 17 años, 5 meses
Puntos: 3
Como eliminar archivo temporal en GIT?

1-Cree un archivo nombre.docx, al crearlo tambien se creo un archivo ~nombre.docx
2-realice cambios en ese archivo
3-hice el commit y el git push
4-cerre todos los archivos y programas, menos el programa de consola de git
5-hice git status y me salio que habia eliminado el archivo ~$nombre.docx (ver pantallazo)

Ese archivo, realmente yo no lo elimine, cuando cerre el word, solito se elimino. Sin embargo, no hubo caso de sacarlo del estado de eliminado. Hice varios intentos que adjunto en la imagen para que la puedan ver. Espero que me puedan ayudar con esto, y decirme que se hace en estos casos.



Uploaded with ImageShack.us

Tambien probe con git rm ~$nombre.docx

Última edición por Gloton; 26/02/2013 a las 06:13
  #2 (permalink)  
Antiguo 27/02/2013, 18:50
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Como eliminar archivo temporal en GIT?

Necesitas usar el flag --cached para eliminar el archivo también del caché.
Código BASH:
Ver original
  1. git rm --cached ~$nombre.docx
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 28/02/2013, 06:43
 
Fecha de Ingreso: octubre-2006
Mensajes: 227
Antigüedad: 17 años, 5 meses
Puntos: 3
Respuesta: Como eliminar archivo temporal en GIT?

Cita:
Iniciado por pateketrueke Ver Mensaje
Necesitas usar el flag --cached para eliminar el archivo también del caché.
Código BASH:
Ver original
  1. git rm --cached ~$nombre.docx
Gracias por responder.
Igual no lo pude borrar usando ese comando.

Todos los pasos que hice para seguir tu consejo fueron los siguiente.
1-en un proyecto git antererior que tenia sin cambios
2-cree 2 archivos, uno prueba.docx y otro que nombre como si fuera un temporal ~$prueba.docx
3-los agregue con git add .
4-despues elimine directo del disco duro(no con un comando de git) el archivo ~$prueba.docx
5-intente borrarlo con el comando indicado git rm --cached ~$nombre.docx

Adjunto pantallazo.



Uploaded with ImageShack.us

Tu puedes probar y crear un archivo que empiece con ~$ y agregarlo al stage y despues ver si lo puedes eliminar?, por favor.


Lo que estoy asiendo ahora es agregando en .gitingnore
~* para que no los vuelva a tomar en cuenta, pero me tiene intrigado porque motivo no los borra.
  #4 (permalink)  
Antiguo 28/02/2013, 16:10
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Como eliminar archivo temporal en GIT?

Debe funcionar, después de eliminar de cache debes hacer commit de ello también.

Aquí el problema que puedes estar teniendo es que el nombre del archivo contiene caracteres especiales y eso arruina las instrucciones.

Pensaba que al estar usando Windows ese no sería un problema, pero veo que si.

Hice la prueba y aquí está el log.
Código BASH:
Ver original
  1. [~]$ cd Sites/
  2. [Sites]$ mkdir fuu
  3. [Sites]$ cd fuu/
  4. [fuu]$ git init
  5.  
  6. Initialized empty Git repository in fuu/.git/
  7.  
  8. [fuu (master)]$ touch candy.txt
  9. [fuu (master)]$ touch \~\$candy.txt
  10. [fuu (master)]$ git s
  11.  
  12. # On branch master
  13. #
  14. # Initial commit
  15. #
  16. # Untracked files:
  17. #   (use "git add <file>..." to include in what will be committed)
  18. #
  19. #   candy.txt
  20. #   ~$candy.txt
  21. nothing added to commit but untracked files present (use "git add" to track)
  22.  
  23. [fuu (master)]$ git add .
  24. [fuu (master)]$ git s
  25.  
  26. # On branch master
  27. #
  28. # Initial commit
  29. #
  30. # Changes to be committed:
  31. #   (use "git rm --cached <file>..." to unstage)
  32. #
  33. #   new file:   candy.txt
  34. #   new file:   ~$candy.txt
  35. #
  36.  
  37. [fuu (master)]$ git ci -m "bar"
  38. [master (root-commit) 28d50e2] bar
  39.  
  40.  0 files changed
  41.  create mode 100644 candy.txt
  42.  create mode 100644 ~$candy.txt
  43.  
  44. [fuu (master)]$ git s
  45.  
  46. # On branch master
  47. nothing to commit, working directory clean
  48.  
  49. [fuu (master)]$ rm \~\$candy.txt
  50. [fuu (master)]$ git s
  51.  
  52. # On branch master
  53. # Changes not staged for commit:
  54. #   (use "git add/rm <file>..." to update what will be committed)
  55. #   (use "git checkout -- <file>..." to discard changes in working directory)
  56. #
  57. #   deleted:    ~$candy.txt
  58. #
  59. no changes added to commit (use "git add" and/or "git commit -a")
  60.  
  61. [fuu (master)]$ git rm --cached \~\$candy.txt
  62.  
  63. rm '~$candy.txt'
  64.  
  65. [fuu (master)]$ git s
  66.  
  67. # On branch master
  68. # Changes to be committed:
  69. #   (use "git reset HEAD <file>..." to unstage)
  70. #
  71. #   deleted:    ~$candy.txt
  72. #
  73.  
  74. [fuu (master)]$ git ci -m "candy"
  75. [master a3d0308] candy
  76.  
  77.  0 files changed
  78.  delete mode 100644 ~$candy.txt
  79.  
  80. [fuu (master)]$ git s
  81.  
  82. # On branch master
  83. nothing to commit, working directory clean
  84.  
  85. [fuu (master)]$ ls -a
  86.  
  87. .       ..      .git        candy.txt
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 01/03/2013, 09:17
 
Fecha de Ingreso: octubre-2006
Mensajes: 227
Antigüedad: 17 años, 5 meses
Puntos: 3
Respuesta: Como eliminar archivo temporal en GIT?

Cita:
Iniciado por pateketrueke Ver Mensaje
Debe funcionar, después de eliminar de cache debes hacer commit de ello también.

Aquí el problema que puedes estar teniendo es que el nombre del archivo contiene caracteres especiales y eso arruina las instrucciones.

Pensaba que al estar usando Windows ese no sería un problema, pero veo que si.

Hice la prueba y aquí está el log.
Código BASH:
Ver original
  1. [~]$ cd Sites/
  2. [Sites]$ mkdir fuu
  3. [Sites]$ cd fuu/
  4. [fuu]$ git init
  5.  
  6. Initialized empty Git repository in fuu/.git/
  7.  
  8. [fuu (master)]$ touch candy.txt
  9. [fuu (master)]$ touch \~\$candy.txt
  10. [fuu (master)]$ git s
  11.  
  12. # On branch master
  13. #
  14. # Initial commit
  15. #
  16. # Untracked files:
  17. #   (use "git add <file>..." to include in what will be committed)
  18. #
  19. #   candy.txt
  20. #   ~$candy.txt
  21. nothing added to commit but untracked files present (use "git add" to track)
  22.  
  23. [fuu (master)]$ git add .
  24. [fuu (master)]$ git s
  25.  
  26. # On branch master
  27. #
  28. # Initial commit
  29. #
  30. # Changes to be committed:
  31. #   (use "git rm --cached <file>..." to unstage)
  32. #
  33. #   new file:   candy.txt
  34. #   new file:   ~$candy.txt
  35. #
  36.  
  37. [fuu (master)]$ git ci -m "bar"
  38. [master (root-commit) 28d50e2] bar
  39.  
  40.  0 files changed
  41.  create mode 100644 candy.txt
  42.  create mode 100644 ~$candy.txt
  43.  
  44. [fuu (master)]$ git s
  45.  
  46. # On branch master
  47. nothing to commit, working directory clean
  48.  
  49. [fuu (master)]$ rm \~\$candy.txt
  50. [fuu (master)]$ git s
  51.  
  52. # On branch master
  53. # Changes not staged for commit:
  54. #   (use "git add/rm <file>..." to update what will be committed)
  55. #   (use "git checkout -- <file>..." to discard changes in working directory)
  56. #
  57. #   deleted:    ~$candy.txt
  58. #
  59. no changes added to commit (use "git add" and/or "git commit -a")
  60.  
  61. [fuu (master)]$ git rm --cached \~\$candy.txt
  62.  
  63. rm '~$candy.txt'
  64.  
  65. [fuu (master)]$ git s
  66.  
  67. # On branch master
  68. # Changes to be committed:
  69. #   (use "git reset HEAD <file>..." to unstage)
  70. #
  71. #   deleted:    ~$candy.txt
  72. #
  73.  
  74. [fuu (master)]$ git ci -m "candy"
  75. [master a3d0308] candy
  76.  
  77.  0 files changed
  78.  delete mode 100644 ~$candy.txt
  79.  
  80. [fuu (master)]$ git s
  81.  
  82. # On branch master
  83. nothing to commit, working directory clean
  84.  
  85. [fuu (master)]$ ls -a
  86.  
  87. .       ..      .git        candy.txt
Gracias por colocar el log, hay varias cosas que quedo perdido, pero creo que este me dara la base, asi que ahora me toca darme el trabajo de investigarlas.
  #6 (permalink)  
Antiguo 01/03/2013, 11:14
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Como eliminar archivo temporal en GIT?

Como sugerencia adicional no olvides agregar dicho filtro en el .gitignore para evitar futuras coincidencias.

Cita:
~*
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Etiquetas: temporal
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:15.