3. Putting the project under version control

Navigating the terminal

Before we initialize our first repository, let's align on how the terminal finds files and directories. A solid grasp of paths will save you from a lot of confusion once we start running Git commands.


Current working directory

Each terminal tab is its own command-line session, and you can keep several parallel sessions open side by side.

Every terminal session begins inside a specific directory on your computer. That location is called the current working directory (commonly abbreviated as cwd).

A directory is the same thing as a folder. Different operating systems use different terms, but they mean the same thing.

While working in the terminal, many commands will operate on files and directories relative to the current working directory. Naturally, you can navigate to different directories as needed.

Most standalone terminal apps start in the user's home directory by default, but this can be changed to any directory. Terminals, integrated into code editors, often open right inside the project directory, so you're usually in the right place from the start.

To check your current directory in the terminal, you can run the

command. It will show you the full path to the current directory.

Task
Completed

Try out the pwd command in your terminal to see the current working directory.

If you want to change the current directory, you can use the

command followed by the path to the directory you want to open.

For example, if your project is in ~/projects/gitbybit, you can run:

cd ~/projects/gitbybit

Your actual project path may be different, so use the path from your own terminal.


Gotchas about spaces and case sensitivity in paths

Note that if the path contains spaces, you need to enclose it in quotes so that the cd command treats it as a single argument.

For example, if the path is C:\Program Files, you would run the command cd "C:\Program Files". You can use both single ' and double quotes ", but always use the same pair of quotes.

For example, if the path is /home/alex/my documents, you would run the command cd "/home/alex/my documents". You can use both single ' and double quotes ", but always use the same pair of quotes.

Also, note that on most operating systems (Linux and macOS included), paths and commands are case-sensitive. For example, /home/Alex and /home/alex are two different paths.


Absolute paths

For example, /home/alex/gitbybit-part1C:\Users\Alex\gitbybit-part1 is an absolute path, a path that starts from the root directory of the file system. Such paths are super specific and always point to the same location on your computer, regardless of your current working directory. However, they are specific to YOUR computer, so they are not that useful in instructions meant for other people.

Absolute paths always start with a drive letter (such as C: on Windows) or a slash character (/, which means the root of the file system on Linux and macOS).


Relative paths

There are also relative paths, which are relative to a current working directory. They are more flexible and portable. For example, file.txt or ./file.txt refers to a file in the current directory, and ../notes/todo.md points to a file inside the notes folder one level up.

Because relative paths are based on the project's folder structure rather than your computer's root directory, the same commands will work on any machine—as long as everyone has the project organized the same way. This makes them ideal for shared projects, version control, and documentation that others can follow without changing paths.

There are special shortcuts like . (current directory) and .. (parent directory). So, to navigate to the parent directory, you can use the cd .. command. This command moves you one level up in the directory tree.

Sometimes you can see paths like this: ./example. That means the same as example (the current directory is implied). So, the cd ./example command is equivalent to cd example.

You can combine these shortcuts with directory names to navigate to a specific directory. For example, to navigate to the example directory two levels higher than your project, you would run the cd ../../example command.

Many command-line tools accept paths as arguments, so you can use this knowledge beyond just the cd command.

SUPER HELPFUL TIP: You can use the Tab key on your keyboard to autocomplete file and directory names in the terminal. For example, if you have a src subdirectory, you can type cd s and then press Tab to autocomplete the command to cd src (or to cd ./src on some systems, which is the same). This is a great way to avoid typos and speed up your work.

Tab completion in the Terminal.
Great, nice to know

You've just learned how paths and the current working directory work, so let's put that knowledge to the test.

At this point, your terminal should be in the project root directory. This is exactly where we want to create our repository. But it never hurts to double-check that you're in the right place. Because sometimes...

Let's do some role-play. Pretend you're a cat trying to help your dear owner while they're away getting coffee. You, the cat, only managed to run one command: cd ~ (do it now). This will change your current directory, but we'll figure out how to navigate back to the project directory in a bit.

Task
Completed

Now, using the commands we've learned so far, navigate the terminal back to the root directory of the project.

Tip #1: If you don't remember what the project directory was, scroll the terminal up until you see the output of the pwd command you ran previously.

Tip #2: If you're not sure what to do next, open a new terminal in the project directory (consider that cheating, though).

Awesome, it seems that you have a good understanding of paths and the current working directory. Let's put this knowledge to use and initialize our repository next.

Next step
Wanna try the Story mode?

Take the course as it was meant to be taken: bite-sized progression, focused linear order, gradually unlock Gitopedia entries. Continue with real Git in VS Code/Cursor/Antigravity/Windsurf at any time.

Story mode
FREE
but requires sign-in