Command Line Setup
Before we get too deep into the workflow, let's get on the same page when it comes to using git bash aka the "command line".
The first thing I want to discuss are some very common commands you will need to know to navigate around and work with the filesystem. These are:
ls # (or ll)
cd [directory to move to]
mkdir [name of directory]
touch [name of file]
cp [name of file to copy] [path where you want to copy file to] cp -r [name of direcotry to copy] [path where you want to copy contents of a directory to]
mv [name of file to move] [location to move to as well as new name for file]
rm [name of file to remove] rm -r [name of directory to remove]
cat [name of file to read]
less [name of file to read]
less
will read a file into a "shell". This is useful for long files that wont fit into your console. You can move up and down the file with you arrow keys, or google "less shortcuts" to get more helpful shortcut keys to move around the file.
You can exit theless
shell by simply pressing q.
Take some time to practice using these commands and do your best to memorize their names and what they do/when to use them.
Getting Help
Almost all commands have some kind of help information that can be printed to the console.
The method of accessing this help information varies from command to command, but generally it will be one of the following:
ls --help
ls -h
ls help
Or for commands that require arguments (like cp
), just typing to command alone without any arguments will print out the help information.
Using a command with invalid arguments will usually also print out some help information along with an error that you are using invalid arguments. Sometimes this help information is specific to whatever arguments you were trying to use, and sometimes it is the generic help information referred to above.
Remember that you can almost always find information on how to use a command by searching it up on Google as well.
If you are using linux or Mac OS, you can also run
man [command name]
To open up a man file that displays help/usage information for a command in detail. This does not work on git bash for Windows.
Paths
When typing out paths for use with these commands, you can move around folders without having to type cd
by using relative paths, just like when you are writing out paths to files for use in your code.../
refers to the path immediately above the current one, and ./
refers to the current path./
is an absolute path. Absolute paths start at the root of the filesystem. In git bash on windows, you will also have to specify a drive letter (i.e. /c/
) in order to accesss any files or directories when using an absoulte path.
If part of path you are trying to access contains spaces or special characters, you will receive an error if you just type them out without properly quoting the path. For example, in order to get into the Program Files
direcotry, I would need to run
cd /c/"Program Files"
~
refers to the home directory, in my case /c/Users/david
.
Ctrl+c
Ctrl+c allows us to terminate an actively running process in the command line. This is useful for stopping some kind of development server, some other running process, or cancelling some task.