git的使用。
添加删除文件
1.如果不小心把bin,obj文件夹给提交到版本库了。
现在发现,想给去掉应该怎么办。
在根目录下创建.gitignore文件
/spark/target
obj
bin
也可以选中不需要的文件夹,或文件->右键->tortoiseGit->Delete and add to ignore list->
delete and ignore 2 items by name
在接下来的窗口中选择如下
Ignore type:ignore items recursively :是递归所有的文件下包含这个文件夹或文件名称的。
Ignore file : gitignore in the repository root 是从根目录开始。
一般选择这两个就可以把当前目录下包含该文件夹名下的全部排除。
处理已经提交到版本库上的忽略文件
如果被忽略的文件已经提交到版本库上。 则采用如下文件
#删除暂存区上的文件
git rm -r --cached .
#重新提交
git add .
git commit -m 'update .gitigonre'
#推送到远程
git push origin master
这样就把仓库里的多余提交的文件夹给删除了。
文件删除恢复
如果不小心把code文件夹删除了。 需要执行以下操作来恢复
git status #查看当前版本和仓库版本区别。
git reset HEAD code
git checkout code
git的cleanup
用的是tortoisegit 右键的cleanup
remove unmanaged directories with .git folder
这篇文章如同一幅色彩斑斓的画卷,每一笔都充满了独特的创意。