debian-mirror-gitlab/doc/university/training/topics/git_log.md

58 lines
895 B
Markdown
Raw Normal View History

2018-03-17 18:26:18 +05:30
---
comments: false
---
2017-08-17 22:00:37 +05:30
# Git Log
Git log lists commit history. It allows searching and filtering.
2019-03-02 22:35:43 +05:30
- Initiate log:
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
```sh
git log
```
2017-08-17 22:00:37 +05:30
2019-03-02 22:35:43 +05:30
- Retrieve set number of records:
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
```sh
git log -n 2
```
2017-08-17 22:00:37 +05:30
2019-03-02 22:35:43 +05:30
- Search commits by author. Allows user name or a regular expression.
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
```sh
git log --author="user_name"
```
2017-08-17 22:00:37 +05:30
2019-03-02 22:35:43 +05:30
- Search by comment message:
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
```sh
git log --grep="<pattern>"
```
2017-08-17 22:00:37 +05:30
2019-03-02 22:35:43 +05:30
- Search by date:
2018-11-20 20:47:30 +05:30
2019-10-12 21:52:04 +05:30
```sh
git log --since=1.month.ago --until=3.weeks.ago
```
2017-08-17 22:00:37 +05:30
## Git Log Workflow
1. Change to workspace directory
2019-02-15 15:39:39 +05:30
1. Clone the multi runner projects
1. Change to project dir
1. Search by author
1. Search by date
1. Combine
2017-08-17 22:00:37 +05:30
## Commands
2019-09-04 21:01:54 +05:30
```sh
2017-08-17 22:00:37 +05:30
cd ~/workspace
2018-03-17 18:26:18 +05:30
git clone git@gitlab.com:gitlab-org/gitlab-runner.git
cd gitlab-runner
2017-08-17 22:00:37 +05:30
git log --author="Travis"
git log --since=1.month.ago --until=3.weeks.ago
git log --since=1.month.ago --until=1.day.ago --author="Travis"
```