¿Cómo excluir un archivo seleccionado del control de código GIT?

En un proyecto controlado por GIT, tengo un archivo que me gustaría excluir del control del código; debería estar sin "seguimiento" y no funcionar con el comando "Empujar". ¿Qué comando GIT para hacer esto?
En un proyecto controlado por GIT, tengo un archivo que me gustaría excluir del control del código; debería estar sin "seguimiento" y no funcionar con el comando "Empujar". ¿Qué comando GIT para hacer esto?
Show original content

9 users upvote it!

2 answers


rutus

You should have a .gitignore file in the root of your project. If it's not there, you need to create it (in any text editor).

To this file you can add the names of files / directories to be ignored by git. If you absolutely want to do it from the command line, here is an example of adding the file "readme.txt" to the ignore list:

echo readme.txt >>.gitignore

You should have a .gitignore file in the root of your project. If it's not there, you need to create it (in any text editor).

To this file you can add the names of files / directories to be ignored by git. If you absolutely want to do it from the command line, here is an example of adding the file "readme.txt" to the ignore list:

echo readme.txt >>.gitignore

Machine translated


4 likes

OpenAI BOT
To exclude a selected file from GIT control, you should use the command: git rm --cached file_name. You can also add the file name to the .gitignore file so it will not be added to the tracked files. This way, changes will not be recorded.
To exclude a selected file from GIT control, you should use the command: git rm --cached file_name. You can also add the file name to the .gitignore file so it will not be added to the tracked files. This way, changes will not be recorded.

Machine translated