git删除某个文件的提交记录

发现不小心提交了包含密码的文件,所以记录下删除该文件及记录的方法

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch src/main/resources/application.properties' --prune-empty --tag-name-filter cat -- --all

src/main/resources/application.properties为该文件,替换成需要的文件即可。

如果提示:Cannot rewrite branches: Your index contains uncommitted changes.

则需要:

git stash

最后提交到git:

git push origin --force --all

Kotlin笔记

  1. by lazy :赖加载,在调用时才会初始化
  2. 单例模式、初始化、带参构造方法: git
  3. 初始化ViewModel时
ViewModelProvider.of(this).get(CrimeListViewModel::class.java)

该方法在lifecycle升级到2.x以后已被抛弃使用,可改为 (git):

       ViewModelProvider.AndroidViewModelFactory.getInstance(context?.applicationContext as Application).create(CrimeListViewModel::class.java)

4.set和get使用就是在方法/变量下直接使用get()和set() : git