Is it possible to combine two git commands into one by assigning it an alias? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Is it possible to combine two git commands into one by assigning it an alias?

30th Oct 2019, 8:48 AM
Anna/Аня
Anna/Аня - avatar
6 Answers
+ 4
Yes you can use && to separate the commands and they should work. This one is an alias set in oh my bash gac='git add -A && git commit -m "init"'
30th Oct 2019, 10:03 AM
xyz$
+ 6
Ankit is there an advantage to using && over ; (semi colon) ?
30th Oct 2019, 10:52 AM
Sonic
Sonic - avatar
+ 5
Jared Bird thanks.
31st Oct 2019, 9:49 AM
Sonic
Sonic - avatar
+ 3
Ankit thank you
30th Oct 2019, 10:11 AM
Anna/Аня
Anna/Аня - avatar
+ 3
Sonic with ; it will run one command then the other. With && it will run one command then only if no error run the next command.
31st Oct 2019, 6:56 AM
Jared Bird
Jared Bird - avatar
+ 1
Sonic I've always used && so i don't exactly know but they are quite similar.
30th Oct 2019, 11:08 AM
xyz$