5

I used to have GoogleDrive on my PC that uploaded all my code on the drive. I was working on the main branch because I got this project on GitHub, so I deleted all the desktop.ini files and tried to pull the project to update the changes made by my co-workers, but got this error.

The problem didn't occur to me at first because GoogleDrive takes a few minutes to make all the desktop.ini, but when it did it caused problems.

> git pull pmo main remote: Enumerating objects: 85, done. remote: Counting objects: 100% (77/77), done. remote: Compressing objects: 100% (33/33), done. remote: Total 59 (delta 25), reused 59 (delta 25), pack-reused 0 Unpacking objects: 100% (59/59), 6.63 KiB | 218.00 KiB/s, done. fatal: bad object refs/desktop.ini error: https://github.com/*******/*******.git did not send all necessary objects 

I tried to remove the .git/refs/desktop.ini with the command rm but it says that i do not have access to it, even in the powershell.

4 Answers 4

4

If a google drive folder (and its subfolders) are shared to other users, a desktop.ini file is created for the current folder and all of its subfolders. Thus, if this shared folder contains a git repo, then the .git folder and all of subfolders (for example, refs, objects where Git stores its own data) will contain a desktop.ini. Git expects all files under .git to contain only Git data, so it fails to understand the file content of desktop.ini. Looks like deleting all desktop.ini is not a good solution as desktop.ini will re-appear several minutes later.

For me, stop sharing the google drive folder works. It automatically removes desktop.ini and won't be regenerated.

Sign up to request clarification or add additional context in comments.

1 Comment

Simply run: find . -name desktop.ini -type f -exec rm -fv {} \;
1

That is why it is preferable to not work in a network-synchronized drive: git pull/push/clone won't work well with the concurrent synchronization that comes with a Google Drive.

It is better to save on that drive a git bundle (which stores your repository in one file), while collaborating with others through the remote GitHub repository (cloned locally in a normal folder)


Ez0r suggests in the comments to use a tool like Everything to search and delete any occurrences of desktop.ini.

6 Comments

Well that would solve the problems if i actually wanted to keep Drive Going, but still i am not able to use the pull.
@Pinguiz You mean: "still i am not able to use the pull": outside any Drive folder?
yes i decided to uninstall Drive and delete all the desktop.ini files, still that problem persists.
search for desktop.ini in that git, then delete all (a tool like "everything" can help)
@Ez0r, thank you!!! Used Everything to search for desktop.ini and deleted them all. Solved a very annoying issue I've had for ages.
|
1

If you are on Windows, you can use the following PowerShell command to recursively obtain all the desktop.ini files and delete them :

Get-ChildItem -Include desktop.ini -Recurse -Hidden | Remove-Item -Force 

1 Comment

This solved it for me!
0

Deleting all desktop.ini files worked for me, but it could not be made manually (there are lots of them).

I used the following code (taken from SharifMrCreed on https://github.com/mhutchie/vscode-git-graph/issues/611):

folder_path = <introduce_your_folder_path> for root, dirs, files in os.walk(folder_path): for filename in files: if filename.lower() == "desktop.ini": file_path = os.path.join(root, filename) try: os.remove(file_path) print(f"Deleted {file_path}") except Exception as e: print(f"Error deleting {file_path}: {e}") 

I hope this helps :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.