0

I have been trying to combine "clear" and "git status" as one command into one git alias. Is there a way to achieve this?? I have tried the following :

git config --global alias.clearall 'clear && git status'  

and also the same using nano ~/.bashrc and add the same alias.

But both don't work. So can anyone suggest another idea ?

  • 2
    What is the meaning of "don't work"? How do you know that it "didn't work"? – j6t Jul 30 '22 at 07:53
  • 1
    Indeed it doesn't work, but the point here is ... well, see [ask] and [mre]. Post good *questions!* – torek Jul 30 '22 at 08:01

1 Answers1

0

Notice in git config you write git commands only for example:

git config --global alias.chst '!git checkout && git status'

Call alias command with git + aliasNAME:

git chst

For more information view this link

But you can alias from ~/.bashrc open ~/.bashrc with any editor that you have for example nano ~/.bashrc and write alias it:

alias clearall="clear && git status"

Call it this command from git bash by writing alias name:

clearall

Eng_Farghly
  • 1,987
  • 1
  • 23
  • 34
  • `&` is most likely wrong. Do you mean `&&`? – j6t Jul 30 '22 at 07:52
  • @j6t I updated the answer but it work in Windows OS – Eng_Farghly Jul 30 '22 at 08:15
  • `&` may "work" for some definition of "work", but it is most likely wrong anyway. Please read up on what the [difference between `&` and `&&`](https://stackoverflow.com/a/26770612/6868543) is. – j6t Jul 30 '22 at 15:33