Jason M
Jason M

Reputation: 1053

Can you log a few commits before and after a specified commit?

Git log -2 {hash} will limit the output to 2 commits after the provided hash. Is there a way to see the 2 commits that came before the has as well?

Upvotes: 1

Views: 72

Answers (1)

rohit89
rohit89

Reputation: 5773

I use

git log --pretty=oneline --reverse --ancestory-path {sha}^..master | head -n

where n is the number of commits you want.

Upvotes: 1

Related Questions