GIT_DISCOVERY_ACROSS_FILESYSTEM error - xcode

Recently I started getting this error everytime I commit to my local Xcode git.
fatal: Not a git repository (or any parent up to mount point /Volumes/xxx)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
I have partitioned my HDD into 2 drives and my source code is on one of them. All my source is local and I'm just using the built in Git with Xcode. Any clues why I get this error?

Check this. You must be missing git init. This is the first command to start with. This command creates an empty Git repository - basically a .git directory

Related

"Not a git repository" after OS reset

This morning my Windows 10 crashed and rebooted once I lifted my laptop's screen. No special activity was progressing, so I don't think there was significant disk activity.
However one of my main Git repos crashed after that reset. Here is what I tried:
$ git status
fatal: Not a git repository (or any of the parent directories): .git
$ git init
Reinitialized existing Git repository in ....../.git/
$ git status
fatal: Not a git repository (or any of the parent directories): .git
Loop
I don't think I have unpushed commits, so wiping and cloning from remote should work.
Still, can I ask what to do to recover an existing Git repository (.git directory still exists, chkdsk reports OK) in such cases?
[Add] read this but did not apply to my case (I can't restore the repo)
As kabanus said in a comment, you should definitely save whatever you can before proceeding (and/or use some other existing clone as a backup).
When Git complains about this, though, it often means that the file .git/HEAD has gone missing. If you create a new HEAD file with contents: ref: refs/heads/master, Git may be able to recover everything.
Since HEAD is the most active file in the repository, it's the one most likely to be clobbered by an OS error or power failure. It's also a critical file when it comes to whether Git believes a .git directory is a repository: if the directory contains a file named HEAD (along with a few other key items), it is a repository; if not, it is not a repository.
I had multiple branches corrupt due to OS error (bloody windows sleep function!!). So I had to manually do the following:
.git/HEAD (set content to ref: refs/heads/master)
$> git branch -v (this will tell you all the corrupt branches)
.git/logs/HEAD (Read the file for last checksum of the commits and merge of corrupt branches)
.git/refs/heads/{corrupt branch file} (change the checksum to the last working checksum from the log file.
merge the branches again as per need.
Another workaround for this, Solved for me while OS crashed on GIT MERGE operation
Get the working HEAD,FETCH_HEAD files under .git/ directory(of your project) from some other contributor
Replace the existing HEAD,FETCH_HEAD files with new ones(taken from other contributor).
Delete the INDEX under .git/ directory.
Then Do a git pull.
In my case, the HEAD file was indeed corrupted due to a system crash.
I just cloned the repo again into a new folder, switched to the branch I was in, then replaced the .git folder with the one I just created from the clone.
From there, it was like nothing happened.
In my case, The ownership of the repo was mismatched after OS reset.
I tried #raheel-hasan's instructions, after entering git branch -v command I got a suggestion.
git config --global --add safe.directory 'direactory path' this command solved the issue :)
(Use powershell to run this command)
You shoult reload your IDE or code editor after running this command.

Git Push is working via Terminal but not via Xcode

I've created a remote git repository on my local computer inside Google Drive folder
git init --bare project.git
and added the remote path as follows
git remote add origin '~/Google Drive/git/project.git'
When I commit via Xcode, it rightly shows the push option check box with correct branch (master in this case). I marked it checked and then press 'Commit and Push' and apparently it does so but actually not pushing to remote repository. When I push from 'Source Control -> Push', it shows successful message but my remote repository doesn't get updated.
When I run the push command from terminal then it does update the remote repository successfully.
git push origin master
How to fix so that Xcode (7.1.1) can push successfully?
Edited: A side note, this has troubled me a lot by the time I realized this. As initially, I think it was working via Xcode (maybe some prior version to 7) as well.
Edited: #VonC here is how I know how git push is working. The modified date gets changed for some objects in finder.
Edited: As per instruction by #VonC, now the push is working from Xcode when project.git is moved at different location out of 'Google Drive' folder. But, I want it to work with 'Google Drive' folder.
Edited: I further moved the project.git to a folder with name including space and again xcode is not pushing but terminal is still pushing.
Xcode 7.1 doesn't push to remote repo path with a space but Terminal does provided that the path is enclosed in quotes. Hope Apple would fix it for new releases.
I've got my issue fixed by renaming the 'Goolge Drive' to 'GoogleDrive' and adjusted the remote path accordingly. Google Drive App prompted for missing folder and I pointed it to the renamed one.
my remote repository doesn't get updated.
Try simply to clone that repo repo elsewhere to see if you get back the content you just pushed:
git clone ~/Google Drive/git/project.git /somewhere/else
Don't forget that a bare repo has no working tree, so after a push, you don't see any new file.
Note: if a remote repo path with a space is problematic to XCode, a possible workaround would be to push to a path without path:
either one which is a symlink to Google Drive
or a path which is rsync'ed after to Google Drive

TortoiseGit Error - Could not get all refs. libgit2 returned: corrupted loose reference file

I just got an error after a recent commit using Tortoise Git:
"Could not get all refs. libgit2 returned: corrupted loose reference
file"
which pops up when I go to check the Log.
Any ideas on how to rectify this?
Your refs are stored inside the raw repository (in .git) in directories (named for each branch) under the "refs" directory. The problem is that one of these files has been corrupted. If you check the code here you'll see that the problem is either that the ref file is less than 40 bytes long, or has a 41st byte that is not a space (or tab, newline, etc). Search through the files in the .git/refs directory and you'll find the bad one. It should contain the 40-character hash of the commit which that branch refers to. You can safely fix it using Notepad.
In my case it was the use of "junction tool" (sysinternals). Got that error only when adding new sub directory and files. Using git bash the problem does not occur. Everything else works fine with "junction tool" and TortoiseGit ...
I had the exact same error and managed to get my repo back without losing my changes.
I:
Made several backups of the corrupt git repository just in case
Cloned the lasted pushed version from the remote repository
Copied all the files from the corrupt .git folder EXCEPT all files related to HEAD, FETCH_HEAD, ORG_HEAD etc ... the most important are the refs, obj, and index
Ended up with a valid history, but corrupt index, applied the solution from this post How to resolve "Error: bad index – Fatal: index file corrupt" when using Git
And my repository was back working ...
To make sure I did not push anything wrong, I cloned again from the remote, checked-out the changes I wanted to save from the restored repository, and comited them fresh.

Cannot clone GIT repository on network drive

Using Windows 7, we have a bare GIT repository set up on a network drive so that multiple users can pull/push from it. I am able to create a new working repo on my local and multiple other networked drives. However, when I try to clone a new working repository on the same network drive (different folder) , it fails.
Using TortoiseGIT, after I right-click and choose "GIT Clone", put in all of the necessary paths to my bare repo (the new working repo is already filled in) and hit ok, I get the following error:
Cloning into 'R:\path\to\new\repo'... done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistent object 5d2164db2c61efc7a5598f6ff75ed3fbbb12456e
fatal: Cannot update the ref 'HEAD'.
fatal: The remote end hung up unexpectedly git did not exit cleanly (exit code 128)
and it fails to create the repo. It does however build the new folder & ".git" subfolder structure.
It's not a r/w permissions issue because I can r/w any other files, but just cannot seem to create this newly cloned repo. My co-worker cannot either. Even if I got to another folder on the network drive, I still cannot clone the repo successfully. Surprisingly, if I just copy/paste a repo I created in another location, then manually do a "pull", it works and updates successfully.
Any ideas on what to try next? Obviously I've Googled "exit code 128" and "cannot update the ref 'HEAD'" but cannot find a solution to my issue. It's probably something really simple that we are overlooking, but we're just getting started with GIT and this is really causing us headaches...
UPDATE: I just noticed that when I do a manual pull from GIT to my "copy", it is doing a Fast-Forward. Maybe this provides some additional clues?
From R:/path/to/repo
* branch master -> FETCH_HEAD
Updating 5d2164d..d75bdb7
Fast-forward
Files.py | 3 +++
1 file changed, 3 insertions(+)
Success
Git might be trying to do some smart stuff with hardlinks that fails on the network drive. Try using git clone --no-hardlinks /r/path/to/my/repo or git clone file:///r/path/to/my/repo
Please do this via command line in msysgit
git clone /r/path/to/my/repo /r/some/other/path
Further, I would recommend using git from the command line as it is a tool that was designed to be used from the command line. You will be able to find more help, faster, with any issues that come up for you.

Setting up a Git repository on MacOS X with network drive

The given:
A mac with my work folder set up as Git repository.
A network drive (Seagate FreeAgent GoFlex Home, if that helps).
The task:
Set up the specific folder on my network drive as a place where a backup of my repository can be stored.
What I tried:
Setting up the location through Volumes path as a Remote (via Add Remote in Git GUI) - returned with:
fatal: GIT_WORK_TREE (or --work-tree=<directory>) is not allowed without specifying GIT_DIR (or --git-dir=<directory>
Then, I tried
git --git-dir=Volumes/xxxxxxx/GoFlex_Home/Personal/xxxxxxxx
in the terminal, and though it did not turn up with an error, it does not appear to be of result, as another try to add remote ended with the same error as above.
After that, I started to have doubts if specifying the path to network drive through Volumes and/or trying to add it as remote are the right things to do to solve the task. Maybe there are other ways to accomplish the goal that I am not yet aware of?
I assume you get these errors because nothing exist yet in the network share. A remote must point to an existing repository, so you first have to clone it: in the original repo do:
git clone --bare . /Volumes/xxxxxxx/GoFlex_Home/Personal/xxxxxxxx
This will copy your repository data to the network folder.
Then you can add it as a remote:
git remote add --mirror=push backup /Volumes/xxxxxxx/GoFlex_Home/Personal/xxxxxxxx
You will be able to synchronize both with:
git push backup

Resources