If I clone a repo and subsequently add one of the downloaded files to .gitignore, I understand I will have to "untrack" them so the .gitignore rules will apply. After untracking them, and are therefore gitignored, are they re-tracked when pulling any updates to those file from the remote repo again?
If the file is still tracked and not ignored in the remote repo, YES. When pulling, it will update the changes to that file. If the file is modified in your local machine, it will raise a conflict.
Actually when you untrack a file, you must push the changes to remote repo, so that the file will be untracked in remote repo as well. If you want to untrack a file only in your local machine there are other ways. Refer: https://stackoverflow.com/a/11209188/1365319
You can also share your ".gitignore" file with your colleges by committing it to the repo, so that they don't accidentally add the file to repo.
The .gitignore
entry will tell the repo not to consider tracking new files. If the file had previously been added to the index and has been tracked, it will continue to be tracked until you remove it from the index. That is, .gitignore
will keep the repo from seeing new files. You still would need to do git rm --cached <file>
to remove the existing tracked item. From that point on, it won't be considered.
Note that editing the .gitignore will affect the entire repo. When you commit and push, the remote repo will then be ignoring and untracking.
If your goal is to only ignore locally and not affect the remote, consider this other SO question:
Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With