git ignore version control of certain files or folders

Sometimes, some of our files are not added in .gitignore, but the files are accidentally submitted on the remote git, and when the file does not want to participate in version control, we can do this

 

 

  1. The first case is to delete files on local git and branches, and at the same time, if you do not want to keep files, you can use the following command
    先执行 git rm file,然后提交 git commit -m"xx",最后push到远程 git push

    If it is a folder, we can replace git rm file with git rm -r file like this

  2. The second, just want to delete the local git and the files on the branch, but need to use it locally, and don't want the file to be managed by git, we can do this

    先执行 git rm --cached file,然后 git commit -m"xx",推送到远程 git push
    最后在 .gitignore添加上该文件,这样就不会被git控制

    If it is a folder, we can replace git rm --cached file with git rm -r --cached file

 

 

The above is that some files do not want to be controlled by git, but they are accidentally submitted, what should I do? I hope it can help you.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325161630&siteId=291194637
Recommended