154

I have searched and read few post but my problem is not the same as described. So here's the issue: using git clone into folder under external partition of the disk works fine but all git commands fails. can't execute git status or git log... I always get error

fatal: Not a git repository (or any parent up to mount parent /home/kozi)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Please help me out..

.
├── abi
├── bionic
├── bootable
├── build
├── cts
├── dalvik
├── development
├── device
├── docs
├── external
├── frameworks
├── gdk
├── hardware
├── libcore
├── libnativehelper
├── ndk
├── packages
├── pdk
├── prebuilts
├── .repo
├── sdk
├── system
└── tools

dejanualex
  • 3,872
  • 6
  • 22
  • 37
user755
  • 2,521
  • 3
  • 18
  • 29
  • what is the output of `tree` inside your git repo? – Chronial May 31 '13 at 13:14
  • ok, what is the output of `ls .git`? You can paste longer outputs on pastebin.com and link to them. – Chronial May 31 '13 at 13:39
  • pastebin has size limits, I uploaded the file [here](http://filebin.ca/j0B9r2q7CYR/repotree.txt) – user755 May 31 '13 at 13:54
  • what’s the output of `ls .git`? – Chronial May 31 '13 at 14:04
  • @Chronial, do you mean .git output of each nested folder in tree? Or is there any specific directory you want me to provide. In root folder I can see only .repo and there is not .git – user755 May 31 '13 at 14:12
  • > /android/.repo$ ls -l .git >total 0 – user755 May 31 '13 at 14:15
  • what command did you use to initialize the git repo? – Chronial May 31 '13 at 14:15
  • "repo init -u https://android.googlesource.com/platform/manifest \ -b android-2.3.7_r1" – user755 May 31 '13 at 14:16
  • @Chronial: any pointers – user755 May 31 '13 at 15:39
  • if you are using the android repo tool, you have to stick to it. See here for more infos: http://source.android.com/source/using-repo.html – Chronial May 31 '13 at 20:18
  • You just need to install git on that partition... Your git install is only valid up to the borders of the partition where it is installed. Pretty sure this is configurable, but regardless, running dual git installations on each drive is a solution that I KNOW will work. No maybes about it. – Nate T May 21 '21 at 01:04

10 Answers10

212

Just type git init into your command line and press enter. Then run your command again, you probably were running git remote add origin [your-repository].

That should work, if it doesn't, just let me know.

mnafricano
  • 2,268
  • 1
  • 14
  • 4
  • 1
    Note, however, that in the insane scenario above, the --force parameter was required to realign the local project & the corresponding remote branch. I was able to do this safely by: 1) making a branch for the local version of localRepo3 (after git init): **git checkout -b local_version**; then 2) setting the branch up to track origin (your command: **git remote add origin [your-repository]**); then 3) **git checkout remote_branch --force**; then 4) a merge of local_version branch into remote_branch. But **git remote add origin [your-repository]** was still the hero here :) – Andrew Faulkner Oct 08 '15 at 02:56
  • GIT_DISCOVERY_ACROSS_FILESYSTEM not set - on heroku .? can you guide me – Sajjad Murtaza Mar 24 '16 at 09:15
  • 1
    You'll get the same error if, for some reason, the .git/index or .git/HEAD files are not writable by yourself. Chown them back to you and the problem goes away. – C. Kelly Sep 18 '20 at 18:47
26

ran across this page and several like it all talking about the GIT_DISCOVERY_ACROSS_FILESYSTEM not set message. In my case our sys admin had decided that the apache2 directory needed to be on a mounted filesystem in case the disk for the server stopped working and had to get rebuilt. I found this with a simple df command:

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:48:43)--> df -h
Filesystem                           Size  Used Avail Use% Mounted on
<snip>
/dev/mapper/vgraid-lvapache           63G   54M   60G   1% /etc/apache2
<snip>

To fix this I just put the following in the root user's shell (as they are the only ones who need to be looking at etckeeper revisions:

export GIT_DISCOVERY_ACROSS_FILESYSTEM=1

and all was well and good...much joy.

More notes:

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:48:54)--> export GIT_DISCOVERY_ACROSS_FILESYSTEM=0

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:57:35)--> git status
On branch master
nothing to commit, working tree clean

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:57:40)--> touch apache2/me

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:57:45)--> git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    apache2/me

nothing added to commit but untracked files present (use "git add" to track)

-->  UBIk  <--:root@ns1:[/etc]
--PRODUCTION--(16:57:47)--> cd apache2

-->  UBIk  <--:root@ns1:[/etc/apache2]
--PRODUCTION--(16:57:50)--> git status
fatal: Not a git repository (or any parent up to mount point /etc/apache2)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-->  UBIk  <--:root@ns1:[/etc/apache2]
--PRODUCTION--(16:57:52)--> export GIT_DISCOVERY_ACROSS_FILESYSTEM=1

-->  UBIk  <--:root@ns1:[/etc/apache2]
--PRODUCTION--(16:58:59)--> git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    me

nothing added to commit but untracked files present (use "git add" to track)

Hopefully that will help someone out somewhere... -wc

10

For complete the accepted answer, Had the same issue. First specified the remote

git remote add origin https://github.com/XXXX/YYY.git

git fetch 

Then get the code

git pull origin master
LSDeva
  • 444
  • 4
  • 8
9

In short, git is trying to access a repo it considers on another filesystem and to tell it explicitly that you're okay with this, you must set the environment variable GIT_DISCOVERY_ACROSS_FILESYSTEM=1

I'm working in a CI/CD environment and using a dockerized git so I have to set it in that environment docker run -e GIT_DISCOVERY_ACROSS_FILESYSTEM=1 -v $(pwd):/git --rm alpine/git rev-parse --short HEAD\'

If you're curious: Above mounts $(pwd) into the git docker container and passes "rev-parse --short HEAD" to the git command in the container, which it then runs against that mounted volums.

rainabba
  • 3,804
  • 35
  • 35
2

The below commands are to initialize git, add remote origin and to ser default upstream

git init
git remote add origin {REMOTE_URL}
git pull origin master
git branch --set-upstream-to=origin/master master
git pull
Thirumal
  • 8,280
  • 11
  • 53
  • 103
1

I came into this issue when I copy my local repository.

sudo cp -r original_repo backup_repo
cd backup_repo
git status
fatal: Not a git repository (or any parent up to mount point /data)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I've try git init as some answer suggested, but it doesn't work.

sudo git init
Reinitialized existing Git repository in /data/HQ/SC_Educations/hq_htdocs/HQ_Educations_bak/.git/

I solved it by change the owner of the repo

sudo chown -R www:www ../backup_repo
git status
# On branch develop
nothing to commit, working directory clean
LF00
  • 27,015
  • 29
  • 156
  • 295
1

Open your CMD, type the below command and hit enter.

git init

Abhinav Singwal
  • 467
  • 1
  • 3
  • 10
0

Check whether you are actually under a github repo.

So, listing of .git/ should give you results..otherwise you may be some level outside your repo.

Now, cd to your repo and you are good to go.

kumar
  • 2,530
  • 6
  • 33
  • 57
-1

For android source code with repo, I beleive you should use REPO. if you really want to use git, you should know if the project has .git directory with ls -a. Or you have to enter the sub project directory which should include the .git.

mick3dell
  • 9
  • 1
-1

The problem is you are not in the correct directory. A simple fix in Jupyter is to do the following command:

  1. Move to the GitHub directory for your installation
  2. Run the GitHub command

Here is an example command to use in Jupyter:

%%bash
cd /home/ec2-user/ml_volume/GitHub_BMM
git show

Note you need to do the commands in the same cell.

BryanMinorPhD
  • 749
  • 5
  • 10