Git: Navigation

Thomas Kohut
2 min readMay 30, 2021

This article discusses the basic navigation commands of GitHub

Navigating through a computer’s files and directories using Git is a basic process that allows users to move through their computer’s files and directories. This can be utilized so that a user may push or pull files and folders from GitHub, which will be discussed in a later article.

Let’s say we want to navigate a folder named “A Destination” located on the desktop. To do this, the first thing a user needs to do is that to confirm that the desktop is located within the directory they currently have selected in git. This can be done using the ls command, which lists out the content located within the current directory.

Result of using the ls command in Git.

Now that we’ve determined that Desktop is in the currently selected directory, we can use the cd command to change our current directory to desktop. Note that the command is not case sensitive; capitalization (or lack thereof) will not affect the result.

Result of cd desktop and ls for the desktop directory.

Upon using the ls command again, we can confirm that our target folder is located within the desktop directory. To access it requires another cd command, but since there is a space in the name, it would have to be inputted differently than Desktop. For names containing a space, quotation marks have be put around the name of the target destination. In this case, it would look like cd “A Destination”. Without the quotation marks, an error would occur.

While this is a simple way of reaching a target folder, this method becomes less efficient and more time consuming when it comes to reaching files in larger directories. A shortcut that can be used to bypass this issue input the filepath as a command. For our example, this would like cd Desktop/“A Destination”. This would set the directory to be the “A Destination” folder, skipping the change in directory to desktop.

What did we learn?

To find out the contents of the directory, use the ls command.

To change the directory, use the cd [DESTINATION] command. If there is a space in the destination name, use quotation marks on that part of the destination (cd “A Folder”).

If the filepath is known, it can be inputted so that one can go directly to the destination (i.e. cd Desktop/“A Folder”).

--

--