Windows - Git: staging fails ==> Invalid argument - windows

I have a file called "adm.php".
I want to transfer this to my repository, but I always get the following error message:
git
-c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks add -f --
adm.php
error: open("adm.php"): Invalid argument
error: unable to index file 'adm.php'
fatal: adding files failed
Completed with errors, see above.
I'm using Sourcetree on Windows 11.
Renaming the file would be difficult, otherwise I would have to adapt some files...
Is there a possibility to define exceptions in the Git configuration or other possibilities?
Thanks in advance!

For everyone who should have the problem and don't know what to do next:
Windows Defender and other anti-virus programs may even mistake certain files for a virus. In my case, this wonderful operating system didn't even notify me even though I activated it ...
Sometimes the solution can be so simple ... Create an exception and now everything works for me.

Related

Git Issue: "cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Bad file descriptor"

I use Git on Windows 10 to track version control for projects I keep on my company's shared network drive. I have a project for which I have been using Git for months with no trouble. I recently created a new branch 'development' and have been using it as a testing environment for new changes before merging the changes back to master. This arrangement has been working fine for the last few commits until now.
I made changes in the testing branch then went to commit my changes but received the below error:
$ git commit -m "this is a commit description"
fatal: cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Bad file descriptor
I now notice this error with many different operations, including git checkout <branch>. The error in this case is:
$ git checkout branch-name
error: unable to append to '.git/logs/HEAD': Bad file descriptor
I'm relatively new to this stuff so apologies if there is an obvious solution here. Any help is appreciated!.
The Bad file descriptor error is coming from your operating system. In C programs (which this particular Git program is), to write to a file, the program is required to first open the file, which produces a file descriptor: a number, usually a small integer such as 3 or 4. Then, to write to that file, the program should make an OS call of the form write(fd, data, len) where fd is an int variable holding the number returned earlier by open.
The Bad file descriptor error means that the number being passed to write is incorrect in some way: perhaps it is out of range or was never returned by an open call, or perhaps it refers to a file that is open, but not for writing. In general, if there are no programming mistakes, this should not happen.
You did, however, mention a shared drive. On Unix-like operating systems, when using networks to access files, things can go wrong that simply cannot happen if the drive is local.1 On these Unix-like systems you would normally get an ESTALE error ("Stale network file handle") rather than an EBADF ("Bad file descriptor") error here, but perhaps this is what is going wrong. In general it's unwise to attempt to use Git across any sort of sharing system: Git really wants full and total control over everything it does, and putting it on any kind of shared system—network drives, Dropbox, OneDrive, Google Drive, etc.—tends to be a bad idea.
This arrangement has been working fine for the last few commits until now.
This behavior is highly characteristic of attempts to use shared file systems with Git: it works great, until it doesn't. If you're lucky, the "doesn't" is merely a minor malfunction like this; if not, it wrecks the entire repository, and since you've been relying on the sharing instead of making clones, there may not be any backup clones from which to fix things.
1Technically, similar things can go wrong, if, e.g., the drive catches on fire. But usually by then the program has stopped running for other reasons. 😅
I was able to resolve this issue by performing the below actions:
Create a local desktop directory
$ cd '<local-directory>'
Clone the repo into this directory
$ git clone '<origin-directory>' .
Make and commit the backlogged changes
$ git commit -m "commit desc"
Break link to remote origin source
$ git remote remove origin
Delete everything in original directory
Copy the contents of the local directory back to the original directory
It seems to work for now but if this happens again I'll just repeat these steps.

Git error: unable to commit specific file - unable to create temporary file: Invalid argument, failed to insert into database, Unable to process path

I have a Git repository which contains the lab work for a course I am currently completing.
Each week when I get given a task, I make an initial commit to push the given resources or any code that I am to make my additions to.
However, upon git commit the following Git error is thrown for an initial commit I am making:
warning: LF will be replaced by CRLF in lab-04/bikky.py. The file will
have its original line endings in your working directory
error: unable to create temporary file: Invalid argument
error: lab-04/biscuit-043.jpg: failed to insert into database
fatal: Unable to process path lab-04/biscuit-043.jpg
The LF warning is grand, I have addressed that.
It's the two error and the fatal warnings that I am unable to address, and I would like to ask what is going wrong here? What checks can I do to this file to figure out what is wrong?
I have ensured the file is present and not corrupted - it matches all other photos given. If I untrack this particular file, and so the commit commits successfully. I do not believe this is a permissions issue.
I realise this may be a question that is very specific to my repository, so I understand if the question is not suitable for SO but if there is anything I can add to get assistance - I will.

Access denied executing compiled program

Using Windows, my Hello World code is in src\hello\hello.go.
When using the command "go run hello.go"
Getting Error like this
# command-line-arguments
C:\go\pkg\tool\windows_amd64\link.exe: cannot create $WORK\b001\exe\a.out.exe: open $WORK\b001\exe\a.out.exe: Access is denied.
This can be caused by an anti-virus application like AVG or G-Data.
You can use the -o argument with go run to specify the output directory, and add that path to the exclude list of your anti-virus should this be the cause.
This usually happens when the executable is being edited in some way, or currently running. Check if you have any spare processes of this executable, or in the worst case, try restarting your computer.
Alternatively, it may also be that the linker genuinely does not have write access to the output directory. Make sure that the directory is writable to the user you are compiling your program as.
Adding code folder to the exception list solved the problem.
Windows Security-> Virus and Threat Protection Settings -> Exclutions->Add folder
Add your workplace folder here where your code exists. Adding temp folder didn't work for me.
go build gotest.go ; .\gotest.exe
Using the above command (regular command prompt.) can eliminate pop-up alerts but don't know the reason.

git "fatal: .git/index: index file open failed: Permission denied"

So, I have been working on a project and have been using git to push to github, and then suddenly today after I have been working for a little while I went to git add and got fatal: .git/index: index file open failed: Permission denied
I can't think of anything I have done recently on my computer that would cause this. Although I woke up today noticing my computer had rebooted overnight, and I noticed some different settings were not how I normally leave them. For instance quiet mode was turned off, and I always have that on. Thought it was kind of weird but ran a virus scan and didn't notice anything so I shrugged it off thinking it may be something on window's end.
Should I be nervous something is playing with my permissions? After a few minutes of googling I haven't found out too much on this error. Kinda baffled because I haven't personally changed any permissions and it everything seemed fine yesterday.
Looking for some help, if there is anything else I need to include to solve this error I'll gladly provide it if asked. Nobody else uses this computer. It is a Windows 10 build, git version 2.6.3.windows.1.
edit: Here's the output
11:21:34.673917 trace.c:319 setup: git_dir: .git
11:21:34.674417 trace.c:320 setup: git_common_dir: .git
11:21:34.674417 trace.c:321 setup: worktree: D:/Downloads/AnotherTabExample
11:21:34.674417 trace.c:322 setup: cwd: D:/Downloads/AnotherTabExample
11:21:34.674417 trace.c:323 setup: prefix: (null)
11:21:34.674417 git.c:348 trace: built-in: git 'add' '.'
fatal: .git/index: index file open failed: Permission denied
Mark: If you have this error in Android studio, just restart your android studio and this error will be solved. I guess that This is because of some 'cache' or 'bug' of intellij idea.
From the verbose output, it appears that the permissions of the .git/index while might have gotten corrupted.
Confirm that this is the case by doing a ls -al .git/index followed by a chmod 644 .git/index to fix it. Then try running the git add command again.
Update
It turned out to be a (Windows) permissions issue. What worked was simply creating a copy from within msysgit of the original folder and using that (i.e. cp -rvf original original-bkup).
A reset of the permissions on the original folder should have worked, but didn't.

Git - Protocol Error - Strange character

I have failed at google, please help.
I have a base Windows 8 OS running Vagrant with Ubuntu 14 (32bit).
When running
git add -A
or
git add *
I get the following message:
addresses▒show.blade.php: Protocol error
I am developing on Windows but gitting through Vagrant.
I can commit and push, but I am sure something is wrong and would like to resolve it before it really causes a problem later.
It looks like there is a strange character between 'addresses' and 'show.blade.php' which may be causing problems in the content of the added tree. You can run git fsck to see if the state of the .git repository has been corrupted. Alternatively you may have redefined add as an alias to do something like 'add-and-push'?

Resources