From 7f68f51eba2ce781058bb09cdd069d8b78a175ba Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 28 Jun 2016 20:33:56 +0300 Subject: [PATCH] Explain that git switches to the root before running any command --- pep-103.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pep-103.txt b/pep-103.txt index 0783104..f6e8e6d 100644 --- a/pep-103.txt +++ b/pep-103.txt @@ -753,6 +753,34 @@ See `WhatIsTheIndex Wiki. +Root +==== + +Git switches to the root (top-level directory of the project where +``.git`` subdirectory exists) before running any command. Git +remembers though the directory that was current before the switch. +Some programs take into account the current directory. E.g., ``git +status`` shows file paths of changed and unknown files relative to the +current directory; ``git grep`` searches below the current directory; +``git apply`` applies only those hunks from the patch that touch files +below the current directory. + +But most commands run from the root and ignore the current directory. +Imagine, for example, that you have two work trees, one for the branch +``v1`` and the other for ``master``. If you want to merge ``v1`` from +a subdirectory inside the second work tree you must write commands as +if you're in the top-level dir. Let take two work trees, +``project-v1`` and ``project``, for example:: + + $ cd project/subdirectory + $ git fetch ../project-v1 v1:v1 + $ git merge v1 + +Please note the path in ``git fetch ../project-v1 v1:v1`` is +``../project-v1`` and not ``../../project-v1`` despite the fact that +we run the commands from a subdirectory, not from the root. + + ReReRe ====== -- 2.39.5