Command + Shift + A or Ctrl + Shift + A
Type registry, click "Registry..."
registry...

Increase the "terminal.buffer.max.lines.count" to 100000 or any number you want, the default is 1000.
terminal.buffer.max.lines.count