In this tutorial you will learn how to ignore tracked files in Git using .gitignore and git rm [–cached] command.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Git Ignore tracked files using .gitignore touch file-1.txt touch file-2.txt git add . git commit -m "add file-1.txt and file-2.txt" vi .gitignore file-1.txt file-2.txt echo "content" >> file-1.txt echo "content" >> file-2.txt git status git rm file-1.txt git checkout -- file-1.txt git rm file-1.txt # Use this option to unstage and remove paths only from the index. # Working tree files, whether modified or not, will be left alone. git rm --cached file-2.txt ls git status |