sh.exe": /bin/git bad file number when git -version - windows

Just installed git and when I run the git bash and enter git -version I get this error: sh.exe": /bin/git: bad file number.
During the installation I had one error but the installation proceeded :"unable to configure the line ending conversion core.autocrif true." Git GUI isn't launching and I get the error : "Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item." Trying to run as admin doesn't change it.

I run into this problem occasionally (including about 5 minutes ago) and I "solve" it by re-installing the Git client.

Related

Bash github project fails to run when cloned on WSL Ubuntu

I have a simple bash script written on a WSL Ubuntu system; it runs perfectly there. I then git push it up to github, and go to a different systems WSL Ubuntu and git clone the project, cd into that folder and run the script, but it is broken with the below errors.
I tried dos2unix on it, but this does not work, same errors and same broken state. Do you have some suggestions about what might be causing this (something is changed by storing it in github I guess), and how to fix (as before, none of the below errors are seen on the originating WSL Ubuntu system, where the script runs perfectly)?
: command not found
: command not found
: command not found
: invalid shell option name
: command not found
: command not found
-bash: .custom: line 147: syntax error near unexpected token `$'{\r''
'bash: .custom: line 147: `fnheader() {
I had the same problem with Windows line endings, so my solution was:
# Remove cloned repo
git config --global core.autocrlf input
# Clone again the repo
Let me know if it works for you too.
Regards.

Push From Git Bash to Heroku

I want to push a project I created to Heroku from Git. I'm running windows and have the Git Bash shell installed as well as the Heroku CLI. Running this from Git Bash shows my Git version:
$ git --version
git version 2.14.1.windows.1
However, when I try from that same Git Bash shell to create my application on Heroku as a remote Git repo, I get an error:
$ heroku create
bash: heroku: command not found
So instead I created my application on Heroku from a regular windows cmd terminal and that worked (i.e., when I log into heroku I see the remote repo). But when I try to do a git push from the windows cmd terminal it does not recognize git:
C:\myapp>git push heroku master
'git' is not recognized as an internal or external command,
operable program or batch file.
Whereas when I try to do a git push from the git bash shell, I get this error indicating perhaps it doesn't know what to make of heroku:
$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
So it seems my regular windows cmd terminal recognizes heroku, but my Git bash terminal does not. How do I configure Git bash to recognize the Heroku command?
Note: When I do a env | grep path from the Git bash shell the results do include my C:/Program Files/Heroku/bin directory, so Git is aware of my Heroku path.
Your problem is not that git would not push to heroku, but that you actually haven't installed git on your system, as the message you posted suggests.
'git' is not recognized as an internal or external command,
operable program or batch file.
At heroku's documentation there is a whole article about pushing to git, if you experience further problems after installing git, you might find a solution there.
Found a solution! It required the following 3 steps/considerations:
First, I followed john g's answer here, which is to close Git Bash and login to Heroku via a windows cmd terminal, then use Git Bash as per normal.
Second, when issuing a heroku command from Git Bash on Windows, include the extension, as described here. I.e., issue heroku.cmd create (instead of just heroku create).
Third, apparently the git push heroku master command must be issued from the same Git Bash terminal where you just issued heroku.cmd create. When I had issued it from a separate terminal I got an error saying "'heroku' does not appear to be a git repository".
I'm posting this, in hopes that it may help others and save them the same trouble I had. This was driving me mad and I tried every solution I could manage to find on the issue. Spent several hours trying to trouble-shoot it. What it actually ended up being was a conflict with my internet security, specifically Comodo Internet Security Premium 10. I received no warning, it just automatically added it to a blocked list on first execution. If you are running internet security software, especially on a Windows machine, this very well could be your issue. Remove the command file found at C:\Users\YOUR_USER_NAME\AppData\Local\heroku\client\bin\heroku.cmd from any block list, as well as any other executables from heroku that may be on the list.

Checkout a git submodule in Xcode 8 Build Phase script

I have a git repo on BitBucket for a utility project and i use it as a git submodule in other projects. I wrote an Xcode Build Phase script that clones, initializes and updates the submodule but it fails cloning with this error:
Cloning into '[Location of my working copy]'...
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
Permission denied (publickey).
fatal: Could not read from remote repository.
I can do a checkout from Xcode's interface, i can do a checkout from the command line, and i can even run the same script from the command line myself, and everything works, i get prompted for my passphrase. Except when the script is run by Xcode.
I contacted BitBucket support and they pointed it out that according to the error Xcode is trying to use /usr/X11R6/bin/ssh-askpass to prompt me for the passphrase of my private key but it can't find the file (i also found that /usr/X11R6 is just a symlink to /opt/X11). They suggested that i check the following links:
https://support.rstudio.com/hc/en-us/community/posts/200660237-Using-Git-with-password-authentication-on-OS-X
https://github.com/markcarver/mac-ssh-askpass
https://github.com/theseal/ssh-askpass
I installed the missing binary from the last link using Homebrew, symlinked it to the location Xcode needs it to be and got a seemingly broken dialog box:
I also tried copying the binary instead of symlinking but it didn't make a difference.
Any ideas?
Just to make sure i ran this test to see if there's a problem with my SSH configs...
$ ssh -vT git#bitbucket.org
...but according to the results everything is OK.
The guys over at https://github.com/theseal/ssh-askpass/ helped me figure this out.
I had to install the missing ssh-askpass then add my SSH key to the agent with ssh-add -c before Xcode was launched. Adding the key while Xcode was running resulted in the Build Phase script always returning an error:
sign_and_send_pubkey: signing failed: agent refused operation
You can read the troubleshooting details here.

git CLI commands error after upgrading to XCode 8

I saw App Store reporting an upgrade to XCode 8 this morning and unfortunately, took the bait. Now, none of the git CLI commands are working. Tried searching on SO and Google but did not find anything helpful, though I did find recent posts of other issues after upgrading to XCode 8. Getting the same error for any git command - as shown below:
%> git status
dyld: Library not loaded: /usr/local/lib/libwep
Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Reason: no suitable image found. Did find:
/usr/local/lib/libwep: mmap() error 1 at address=0x10F0E5000, size=0x0000F000 segment=__TEXT in Segment::map() mapping /usr/local/lib/libwep
/usr/local/lib/libwep: mmap() error 1 at address=0x10F103000, size=0x0000F000 segment=__TEXT in Segment::map() mapping /usr/local/lib/libwep
git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
As it says, /usr/local/lib/libwep does exist but there is an error when trying to load it. Also, the xcodebuild executable also exists at the path printed in the message, i.e. at /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
I also see another xcodebuild at /usr/bin/xcodebuild but / is not accepted as a valid DEVELOPER_DIR value. Some more possibly useful information: I have Github Desktop installed. So I made a change in one of the source files in my Git repo, and Github Desktop showed the local change successfully in its GUI. However, neither git diff nor git status works from the command-line.
I also tried cloning a fresh local repo but git clone throws the same error, too.
Looks like this is not related to XCode. I found the following after some searching: https://forums.developer.apple.com/thread/7862
So, libwep is used by WebSense, an application that is installed by default on all computers in the corporate environment I am working in. It is meant for security and restricts certain operations. For example, I can not execute any Heroku CLI commands, either, because of it.
What threw me off was that, even with WebSense, I was able to run git CLI commands until last week, but then I also installed a new version of the WebSense client late last week. So it may be the new WebSense version that is now blocking git CLI commands, too. That I installed XCode 8 today could be just a coincidence, or another possibility is that the XCode 8 upgrade in combination with the WebSense client upgrade resulted in this situation.
Anyway, thankfully, Github Desktop still seems to work so I'll just have to use that.
If you don't develop anything on Xcode just delete Xcode from program files and run git from CLI again. The required tools will be downloaded automatically. No issues.
I did have the same issue this morning when I tried to use my git. I had to go in and delete the program and reinstall the git client for mac. It started working for me after that.

Cygwin failing to open .git/config

I believe that I am missing something obvious.
I am using Windows 8.1 in VMWare Fusion on a Mac OS X host. I have installed Git as a Windows component, and I also installed Git as a Cygwin component.
I was able to use all my usual Git commands on Cygwin within a versioned directory. However, when I tried to push, I was notified that I have not yet associated my e-mail or name (git config --global user.name <name>; git config --global user.email <email address>).
When I ran those commands, I got a permission denied. Afterward, I was unable to issue ANY git command (status; show; pull; fetch; etc...).
I received the following error in Cygwin:
fatal: permission denied opening .git/config
UPDATE: I seemed to have resolved this by deleting my Cygwin C:\cygwin64\home\<user>\.gitconfig file. Any idea what may have been going on?
I believe that there is an issue when a .gitconfig is in the Cygwin home directory and there's a config file in the actual C:\Users\<user>\.git\ folder.
Am I missing something?
I seemed to have resolved this by deleting my Cygwin C:\cygwin64\home\.gitconfig file.

Resources