Basic Git Bash Console Commands

Basic Git Bash Console Commands

A cheat sheet for basic filesystem commands in the Git Bash console.

Installing the Git Bash Console

We will be using the Git Bash console.
To use it, you need to have Git and Git Bash installed.
Install from the site: https://git-scm.com.

Commands in the Git Bash Console

clear – Clear console

Navigation

pwd – Show current directory
ls - Show files in this folder, except for hidden ones
ls -f – Show files in this folder, including hidden ones
cd c:/ – Go to a specific directory
cd - – Come back
cd .. – Exit 1 level up
cd ../.. – Exit 2 levels up

Creating directories

mkdir – Create a folder
cd !$ – Go to the newly created folder
mkdir -p {app1,app2} – Create multiple folders at once
mkdir -p app/{css,js} – Create several subfolders at once

File creation

touch index.html – Create index.html file
touch app/{css/main.css,js/main.js,index.html} – Create several files at once, no extra spaces should be

Deleting files

touch – allows you to create files
rm test – Delete empty test folder
rm -r test – Delete the test folder with files inside it

Moving files

mv app1/*.* app2 – Move all files from app1 folder to app2 folder

Leave a Reply

Your email address will not be published. Required fields are marked *