He añadido un archivo llamado "archivo1.txt"a un repositorio Git. Después, lo he confirmado, he añadido un par de directorios llamados
dir1y
dir2`, y los he confirmado en el repositorio Git.
Ahora el repositorio actual tiene "archivo1.txt",
dir1, y
dir2. ¿Cómo puedo eliminar
"file1.txt"sin afectar a los demás, como dir1
y dir2
?
Utilice git rm
:
git rm file1.txt
git commit -m "remove file1.txt"
Pero si quieres eliminar el archivo sólo del repositorio Git y no eliminarlo del sistema de archivos, utiliza
git rm --cached file1.txt
git commit -m "remove file1.txt"
Y para empujar los cambios al repo remoto
git push origin branch_name
De forma más general, git help
ayudará al menos con preguntas sencillas como ésta:
zhasper@berens:/media/Kindle/documents$ git help
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents to the index
:
rm Remove files from the working tree and from the index
Si tienes la aplicación GitHub para Windows, puedes eliminar un archivo en 5 sencillos pasos: