我需要排除一个文件夹(名称上传)从跟踪。我试着逃跑
git rm -r --cached wordpress/wp-content/uploads
之后我添加了。gitignore的路径
/wordpress/wp-content/uploads
但是当我运行git状态时,它们显示为已删除。如果我试图提交更改,文件将被删除,而不仅仅是从跟踪中删除。
我做错了什么?
我也试过
git update-index --assume-unchanged <file>
但这似乎只取消跟踪文件。但是我需要从跟踪中删除整个文件夹(包括子文件夹)。
我也是一个初学者,下面是我的解决方案。这个问题应该很容易解决:
In your terminal, make sure you are in the correct folder. For me, it should like: my-MacBook:~ myUserName$
Input: git status
It should give you a list of folders and files that git tracking now. Copy them.
Input: code .gitignore
Your default code editor will open this file, or you can find it and open manually.
Paste the list of folders and files name from step 3. Make sure there is no tab or space at beginning of each line.
Save and close this file (.gitignore)
Go back to the terminal and input: git status
If you see the untracked files only have: .gitignore, it means it works now.
Input: git add .gitignore
Input: git commit -m "what ever message you want to left here"
Now you should be all set!