.gitignored文件仍显示在RStudio中

Mar*_*ann 6 git r rstudio

我添加的文件夹.Rproj.user.gitignore.但是,它中包含的一些文件仍然显示出来(见截图).任何想法我能做些什么呢?

在此输入图像描述

更新

添加后无变化 .Rproj.user/**

在此输入图像描述

Cod*_*ard 16

首先,您的文件已经提交,因此您必须将其从repo中删除:

# Once you add files to git, it will keep tracking them,  
# so we have to delete them and commit your deletion
git rm -r --cached .Rproj.user/**

# Commit the deleted files
git commit -m "Removed files...."

# now add it to the `.gitignore` and the files will be ignored
echo '.Rproj.user/**' > .gitignore
Run Code Online (Sandbox Code Playgroud)

添加这个:

# Once you add files to git, it will keep tracking them,  
# so we have to delete them and commit your deletion
git rm -r --cached .Rproj.user/**

# Commit the deleted files
git commit -m "Removed files...."

# now add it to the `.gitignore` and the files will be ignored
echo '.Rproj.user/**' > .gitignore
Run Code Online (Sandbox Code Playgroud)

您需要将其标记为文件夹.
为此,添加**如上所述的2

在此输入图像描述

P.S.

这是一个很酷的钩子,它会阻止你尝试将它们推送到服务器时添加的那种文件.

有什么比.gitignore更强大的方法来保持(强制)文件不被回购?