I've seen this question, which tells how to get the path of a particular file relative to the root of the git repo. But I now want to get the path of the current directory, not a specific file. If I use
git ls-tree --full-name --name-only HEAD .
I get the list of all the files in the directory.
Is this possible?
Use the terminal to display the . git directory with the command ls -a . The ls command lists the current directory contents and by default will not show hidden files.
By default, the project repository is located under the root directory. The folder is named by the project's unique ID (GUID), and supports only local path drives (C:\) and UNC paths (such as \\system\Remote Repo).
On the GitHub website, click on you repository of interest. Locate the green button named Code and click on it. The GitHub URL will appear.
Whenever inside a git repo and want to cd to its root, typing gitroot will take you to its root dir.
How about:
$ git rev-parse --show-prefix
From man git-rev-parse
:
--show-prefix
When the command is invoked from a subdirectory, show
the path of the current directory relative to the top-level
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With