git - Tell git that modified line is not new line
问题描述
I modified a parameter on a function and now git recognizes it as an entirely new line of code. The first line of code below represents the original code, and the second line represents the "new" line after I changed one parameter. The first line was originally on line 1 and the new line is now on line 10 (because I didn't make an atomic commit, and I believe this is the main problem).
// on line 1 originally
const myFunction = (someArray: Array<{ id: string; name: string; }>, index: number) => {
// now on line 10
const myFunction = (someArray: Array<{ id: string; name: string; }>, index: string) => {
Is there any way to tell git that line 10 is just line 1 modified so that it doesn't seem like so much churn is happening?
解决方案
这真的没有意义。Git 会在每次提交时跟踪文件的全部内容。唯一可以将事物称为“添加”、“修改”或“删除”的时间是当您区分两件事时。对于已移动的行,这将始终被差异工具视为删除和插入。
推荐阅读
- python - Python3——对象路径……坏了?
- npm - npm publish 给出“无范围的包不能是私有的”
- swift - 安全区域布局指南不适用于 UITableView 的 BackgroundView
- bash - 如何从 bash 循环的输出创建表格矩阵?
- javascript - 如何在不使用 slurp 标志的情况下将 JSON 序列与 jq 组合?
- grails - Grails 3,登录后的Spring Security Rest用户名
- android - Crashlytics 未上传映射文件
- r - 从嵌套数据框列表中替换数据框变量中的值
- google-app-engine - 在 Google App Engine 柔性环境中启用 CORS
- angular - NGXS - 在 actions$ 流中处理动作生命周期