Git

How Can I Display the Current Branch and Folder Path in Terminal?

Git branches are ways of saving organized data in the repositories through committing from the staging index. Developers can generate and switch local as well as remote branches. Sometimes, users need to show the name of the current working branch, they can get it by utilizing the Git commands. Additionally, Git provides multiple commands for displaying the path of existing files and folders.

This write-up will explain:

How to Display the Current Branch in Terminal?

To only display the current working branch name in the Git terminal, type out the “cd” command with the Git root directory path and navigate to it:

$ cd "C:\Users\nazma\Git"

Now, run the “git branch” command along with the “–show-current” option:

$ git branch --show-current

As you can see, the below-given output shows the name of the current working branch name:

How to Display the Current Branch and Folder/File Path in Terminal?

If you want to view the name of the current working branch and folder/file path in the Git terminal, the “git status” provided command can be used:

$ git status

According to the below-given output, the “gemma” is the current working branch and all staged/unstaged files are displayed with their folder path:

That’s all! We have described the easiest way of showing the current working branch and file/folder path in the Git terminal.

Conclusion

To show the current working branch and file/folder path in the Git terminal, first, redirect to the Git root directory and execute the “git branch –show-current” to just view the branch name. If developers want to check the current branch name with the file/folders name, then use the “git status” command. This write-up illustrated the way of displaying the current branch and file/folder path in the Git terminal.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.