How to remove version control of a folder in git

http://www.tuicool.com/articles/NfEzeq

The directory structure is as follows

project
    bin
    lib
    src
    ...... 

Do the following

git add .
git commit -m "add bin/ lib/ src/"
git push origin master

Suddenly found that the original libdirectory does not need to be submitted to the repository, but now the directory already exists remotely, what should I do. (Can the spit out be recovered)

Almighty git, help me!

The hard work paid off and found a solution to the problem, which is actually git rmthe command line parameters of .

git rmCommand parameters

-n --dry-run 
Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.
-r 
Allow recursive removal when a leading directory name is given. 
--cached 
Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.

Solution

git rm -r -n --cached "bin/" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
git rm -r --cached  "bin/"      //最终执行命令. 
git commit -m" remove bin folder all file out of control"    //提交
git push origin master   //提交到远程服务器

At this point, git statusyou can see that the bin/ directory status changes tountracked

You can modify the .gitignorefile to add bin/and submit the .gitignorefile to the remote server, so that version management of the bin directory is not required.

When needed in the future, you only need to comment .gitignorethe #bin/content and re-execute it git bin/, and then it can be incorporated into the version management again.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327058465&siteId=291194637