Is there any command in Git, that clear the screen. for example in window command line after execute a lot of code, if you type cls, then it will clear all the previous code. so i want the same type of functionality in Git. so can anybody will tell me the command name.
-
2Are you asking about [clear(1)](http://linux.die.net/man/1/clear)? – Carl Norum Sep 09 '13 at 18:06
-
1ok. i got it. i just type clear. it remove all the previous lines. – naresh kumar Sep 09 '13 at 18:09
-
4ctrl+l also usually works – wasatz Oct 30 '13 at 10:41
10 Answers
Actually you are looking for a Unix user environment command
clear
or you can use the keyboard shortcut
ctrl+l
http://en.wikipedia.org/wiki/Clear_(Unix)
To clear entire command history in Git Bash.
history -c
-
1Works under Windows, if you are running GIT Extensions (http://code.google.com/p/gitextensions/) and run a GIT Bash prompt. – Contango Jan 14 '14 at 11:11
-
3
-
7It does not work, it only moves everything up. It does not help to look through output lines after cleaning. – Yevgeniy Afanasyev Jun 14 '16 at 05:14
-
9You might prefer to use `reset` so it gets rid of the buffer as well. See [this answer](http://superuser.com/a/123185) – Daniel J.G. Nov 07 '16 at 16:48
-
2When using `clear` multiple times, I've found that it only allows me to scroll back to the previous `clear`. Is that the usual effect? If so, is there a command that does `scroll-up-so-that-the-next-command-is-the-only-one-I-can-see-but-the-history-is-still-preserved-if-I-want-to-scroll-up-to-it?`. PS Prize for most hyphenated string? ;) – ro͢binmckenzie Oct 03 '17 at 16:53
-
This works, if you do ``history -c``` then clear everything is gone – samarmohan Oct 26 '20 at 20:00
try using reset command, it will absolutely clean your screen but you will still have access to previous commands
reset

- 5,596
- 5
- 42
- 50
-
5Nice! `clear` command simply moves your scrollbar in a fashion that you see a clear screen in front of you. So if you scroll up you can still see the output of the commands you had fired previously. `reset` command resets the screen scrollbar and flushes the output of all previous commands as well. So we can say `clear` command is soft clean and `reset` is hard clean :) – RBT Mar 23 '17 at 01:28
-
1`reset` command reinitializes the terminal, as if it was reopened from scratch. – RBT Mar 23 '17 at 01:30
-
1One way in which `reset` is **not** like reopening from scratch is that your current directory is retained. Also, the command history that gets carried over when you open a new Git Bash terminal completely from scratch is... somewhat wonky, particularly if you've opened several instances, closed *some* of them, then opened yet more new ones. If you do `reset`, then you know that the command history *in that particular instance* is still there. So yeah, `reset` is *exactly* what you want in most situations, and much better than "from scratch". – John Y Feb 22 '22 at 14:38
-
1To put it simply: `reset` in Git Bash is the closest thing to `cls` in a Windows command prompt, which is what the question is asking for. So this is a much better answer than `clear`. – John Y Feb 22 '22 at 14:52
Neither clear
nor history -c
does the work actually.
Scroll up, all commands will be visible.
Solution:
If you are in Windows 10, and using mintty 2.7.9 (or above ?) for git bash,
use Alt + F8 ... this will work.
Best of luck.
Happy coding.
Reference: here (Perhaps it didn't work for Windows 7)

- 779
- 7
- 25
Neither clear nor history -c was clearing the history permanently.
All commands will be visible when scrolled up.
So, I solved the issue by:
In my instance the path for bash history was:
/c/Users/<your_username>/.bash_history
I removed the file by the following commands:
rm ~/.bash_history
After that, I restarted the terminal. the commands were gone.

- 3,258
- 1
- 21
- 20

- 111
- 2
- 4
Another option is modify (or create in your user folder) your .bash_profile and add this:
alias cls='clear';
With this you can clear the bash with a 'Windows' command.

- 283
- 3
- 17
At the moment I use
clear;reset;clear
(in one line) and it sort of works (git version 2.32.0.windows.1).

- 16,368
- 4
- 94
- 127
Most times clr, clear and cls doesn't work use ctrl c to continue writing commands
use clear only without git command
" clear "

- 3
- 3
-
This was already suggested in 2013. See the accepted answer. What's the point to send duplicate answers? – Alex Shesterov Jul 22 '20 at 11:29