Git命令和配置技巧(3)

git reflog 列出最新修改记录 也可以 git log --oneline
git log 00788a04 --name-status 找到对应版本号 执行

commit 00788a04f8d6dd834723c3479a0b5cdcfad8694a Author: ZhiChao <13424490552@163.com> Date: Thu Mar 30 11:04:46 2017 +0800 最后一条消息显示来源人 M yjtim/IM/Chat/Controller/ConversationListController.m commit a4b9129f1728dc10d5f6ab8c77c1b20ef7bb3d12 Author: ZhiChao <13424490552@163.com> Date: Wed Mar 29 17:49:44 2017 +0800 隐藏被入群弹框 M yjtim/IM/Chat/Controller/ChatDemoHelper.m commit 1910008369d4ab264e7610997135a54d27fe22c7 Author: ZhiChao <13424490552@163.com> Date: Wed Mar 29 17:40:56 2017 +0800 99+ M yjtim/IM/EaseUI/EMUIKit/Views/conversation/toolbar/EaseImageView.m

git diff HEAD@{79} HEAD@{78} 具体某次修改的内容(具体某次内容和上次的内容进行比较)
git diff a4b9129f 00788a04 当然也可以使用版本号

这样假如之前修改过具体某些内容,以后还需要修改的话,找起来真的很方便.好比某些bug好久之后才发现,又要回头去修改,而修改总要找到对应的代码进行修改吧,这样几行命令就定位到具体文件和位置了,方便多了,节省很多时间.找代码有技巧,但是"找"终究还是很浪费时间.这也告诉我们,commit 提交命令很重要,需要认真写,不可为了省事而乱写

diff --git a/yjtim/IM/Chat/Controller/ConversationListController.m b/yjtim/IM/Chat/Controller/ConversationListController.m index df0555e5..71822638 100644 --- a/yjtim/IM/Chat/Controller/ConversationListController.m +++ b/yjtim/IM/Chat/Controller/ConversationListController.m @@ -347,7 +347,7 @@ - (NSAttributedString *)conversationListViewController:(EaseConversationListView [attributedStr setAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:1.0 green:.0 blue:.0 alpha:0.5]} range:NSMakeRange(0, NSLocalizedString(@"group.atMe", @"[Somebody @ me]").length)]; } else { - attributedStr = [[NSMutableAttributedString alloc] initWithString:latestMessageTitle]; + attributedStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@:%@",[[YJTAddressList shareAddressList].userNameDict objectForKey:lastMessage.from],latestMessageTitle]]; } } 方法二

直接使用git log 6b81a31033 -p 或则 git log -p 6b81a31033 其中6b81a31033为版本哈希值

commit 6b81a31033074ef279049e9cbf5944e3158d7510 Author: ZhiChao <13424490552@163.com> Date: Fri Apr 14 13:57:22 2017 +0800 综合评价fixbug diff --git a/yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaDetailVC.m b/yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaDetailVC.m index 10ff4b31..cef73191 100644 --- a/yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaDetailVC.m +++ b/yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaDetailVC.m @@ -28,7 +28,7 @@ @interface YJTEvaDetailVC ()<YJTEvaDateSelectVCDelegate> @property (nonatomic, strong) NSArray *catListArray; @property (nonatomic, strong) YJTEvaSchoolYearModel *evaSchoolYearModel; - +@property (nonatomic, copy) NSString *formId; @property (nonatomic, copy) NSString *className; @property (nonatomic, copy) NSString *classId; @property (nonatomic, copy) NSString *tempClassId; @@ -262,6 +262,7 @@ - (void)rightBtnClick { editVC.evaListModel = self.evaListModel; editVC.catListArray = self.catListArray; ... 方法三

git log --stat 6b81a31033或者git log 6b81a31033 --stat 查看简洁文件变化

commit 6b81a31033074ef279049e9cbf5944e3158d7510 Author: ZhiChao <13424490552@163.com> Date: Fri Apr 14 13:57:22 2017 +0800 综合评价fixbug yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaDetailVC.m | 5 +++-- yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaEditVC.h | 1 + yjtim/Sections/Apps/NewEvaluation/Controller/YJTEvaEditVC.m | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 7.忽略跟踪 git checkout . 清空所有更改 以下命令是我们在项目中已经添加了.gitignore 但是中途突然不想再跟踪某文件 此时发现简单的在.gitignore文件中添加要忽略的文件是不起效的,因为该文件已 经被track,我们还需要将其状态改为 未track(其实只需删除暂缓区文件然后将操作体检即可) git rm --cached Podfile.lock 将Podfile.lock从暂缓区删除,不再跟踪 8.备份

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13244.html