You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is how your scripts may discover what is the root directory of your git project using the git command.
Say you are in a directory beneath the git project named learn-git.
cd ~/dev
git clone git@github.com:ebouchut/learn-git.git
cd learn-git
cd img
pwd
# => /Users/ebouchut/dev/learn-git/img
# ~~~ Show the **absolute** path of the git project we are in we are in
git rev-parse --show-toplevel
# => /Users/ebouchut/dev/learn-git
# ~~~ Show the path of the git project we are in **relative** to the current directory
git rev-parse --show-cdup
# => ..
IMPORTANT: For this shell command to work you must launch it from within a clone of your git repository.
In the above example, I cloned this repository and cd into it then cd into the img folder.
I'm now in /Users/ebouchut/dev/learn-git/img.
Both variants of this command returns the git project's "root" directory:
the first one gives the absolute path /Users/ebouchut/dev/learn-git
the second one the path relative to the current directory you are launching the command from: ..
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Here is how your scripts may discover what is the root directory of your git project using the git command.
Say you are in a directory beneath the git project named
learn-git
.IMPORTANT: For this shell command to work you must launch it from within a clone of your git repository.
In the above example, I cloned this repository and
cd
into it thencd
into theimg
folder.I'm now in
/Users/ebouchut/dev/learn-git/img
.Both variants of this command returns the git project's "root" directory:
/Users/ebouchut/dev/learn-git
..
Beta Was this translation helpful? Give feedback.
All reactions