Checkout a git submodule in Xcode 8 Build Phase script - xcode

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.

Related

warning: templates not found /usr/local/git/share/git-core/templates

I get this error warning: templates not found /usr/local/git/share/git-core/templates when I cloning repo in local repository this link, this link, and this link I tried this method and I just waiting more than 20 minutes but repo doesn't clone. I use source-tree and OS X El Capitan. How can I fix it?
Create a templates folder.
In your case, it should be: mkdir /usr/local/git/share/git-core/templates
I was also getting same error
warning: templates not found /usr/local/git/share/git-core/templates when I cloning repo in local repository then i found solution which solved my issue.
I Added the [init] section to .gitconfig in home directory, so that it looked at SourceTree's git templates directory when cloning a repo:
[init]
templatedir = /Applications/SourceTree.app/Contents/Resources/git_local/share/git-core/templates
Hope it will help you!.
In case of Source tree on macOS
Steps:
Source tree Menu
Preferences
Git
Click on System Git under Embedded Git Version 2.2.1
Reset to embedded Git
Restart source tree
Similar to Rohit's answer, I went into SourceTree's Tools->Options->Git and selected "Update Embedded Git". After the latest Embedded Git version was installed, the warning stopped occurring.
Cloning via SourceTree for Mac, the download was stuck at 99% and I was getting the same error:
warning: templates not found /usr/local/git/share/git-core/templates
I started looking up the issue and found this Question. Was about to start with some of the Answers here...
But then it finally completed. So, my Answer: wait a bit longer. Mine was cloning for 10 minutes or so.
#wonderfulthunk's comment works for me:
sudo mkdir -p /usr/local/git/share/git-core/templates && sudo chown -R my_username /usr/local/git
I followed below steps and I am able to get through this issue in Windows 10.
Step1:
First know the path of %USERPROFILE% using below command in command prompt.
echo %USERPROFILE%
Please note that, you can also run git config --list and look for init.templatedir for the path.
Step2:
Look for .git_template folder in it.
If is missing, please run below command to add it.
git config --global init.templatedir "%USERPROFILE%.git_template
Step3:
Create a folder namely templates in it.
After creating this templates folder, I did not get the warning mentioned i.e. 'templates not found' any more.
MacOS: Ventura 13.0 /
Sourcetree: 4.2.0
I fixed warning: templates not found /usr/local/git/share/git-core/templates by going to "Sourcetree preferences -> Git" and clicking to "Use System Git". There's no need to restart Sourcetree, just try to clone again.
I didn't switch to usage of embedded Git again, all works perfectly with usage of System Git.
In my case, this happened because an unaccesed project. Check that you have all the privileges to clone that repository.
If you use Sourcetree application, switch git version from "Embedded Git" to "System Git" in setting.
https://community.atlassian.com/t5/Bitbucket-questions/About-git-path-for-Sourcetree/qaq-p/186483
And after changing git version, if you still have problem with cloning, change protocol from "ssh" to "https".
I couldn't get past this problem. Even after getting rid of the 'templates not found' error by adding the usr/local/git... folder, the clone would still look like it was at 99% and sit there for HOURS. I just clone via command line and it's there in seconds, then I just add the local repo to Sourcetree instead.

msysgit cannot pull tags

When doing a git pull on a project with GIT tags, I get the error below.
I use msysgit on Win8, versions:
git-gui version 0.19.GITGUI
git version 1.9.5.msysgit.1
Tcl/Tk version 8.5.13
The error I get is:
$ git pull --tags
Enter passphrase for key '/c/Users/Me/.ssh/id_rsa':
fatal: Unable to create 'c:/Users/Me/someproject/.git/refs/remotes/origin/lpt1.2-support.lock': No such file or directory
fatal: The remote end hung up unexpectedly
Any clues?
I think the ssh couldn't find your keys. Make sure they are in the default location.
Try to clone the remote. If you are not able to clone and you get the message "The remote end hung up unexpectedly". We can suspect that the your ssh key is not in the default location.
If you are able to clone, and couldn't pull check if you have any locks and the directory exist on your local. c:/Users/Me/someproject/.git/refs/remotes/origin/lpt1.2-support.lock
On msysgit, check if the variable HOME is set. HOME can be set to any directory you want, you only have to make sure you have the right to write in it (and that the directory exists and a .ssh under it exists too).
ssh-keygen -t rsa
And follow the prompts there.
If the problem is solved could you please let me know which of the three cases above helped you.

git on Windows: fatal: protocol error: bad line character: #-

I was using SourceTree + Git on Windows without any problem. I was able to use git commands from command (terminal/BASH). I prefer to use terminal for git push/pull etc. Unfortunately, after reinstallation of my machine (server/git are the same), I'm getting this painful error.
On a new machine, I installed Git 1.9.5 (Git-1.9.5-preview20141217.exe) and configured to use BASH only and plink with proper SSH key file.
I can do git log on my repository, but git pull or git push gives this error:
me#NEW-MACHINE /c/Workspace/project (master)
$ git pull
fatal: protocol error: bad line length character:
#-
ERROR: Problem parsing the command line arguments.
Of course, I searched many articles related to "fatal: protocol error: bad line length character". But, couldn't find any clue.
Interestingly, on SourceTree, I can do git pull or push successfully. I'm only getting this error in BASH terminal. Note that SourceTree doesn't use embedded git.
Here are my investigations so far:
I installed an older version of git (1.8.x), still getting error.
Moved .bashrc, but no good.
Obviously, not a problem of SourceTree as SourceTree doesn't use embedded Git.
The server is in Github (enterprise, private).
I have no problem using any git commands on my Linux with the same git repository/server.
My clue is <newline>#-<newline> from the error message. It is more like a problem of Windows/BASH-specific problem. I can't figure it out what causes "#-".
Edit: I tried suggestions in this thread, but didn't solve my problem. The git server is github.mycompany.com, which doesn't allow any ssh connection.
You can circumvent the bash-ssh issue entirely by:
launching a DOS shell with git-cmd.bat (packaged within your Git for Windows msysgit distribution)
using git clone to make a new clone using the proper https url of your remote repo.
That is:
git clone https://<yourAccount>#github.mycompany.com/<yourAccount>/<yourRepo>
Since you will be using in this case the https protocol, there won't be any shell session during a git pull (as opposed to the ssh protocol: see The Smart Protocols), and you shouldn't see any extra message like fatal: protocol error: bad line length character.
I had same issue for git in windows.
Load your public/private key by Pageant App (Putty Authentication Agent).
add private/public key.

How do I unlink my computer from a github account?

I've been able to push with the mac GitHub app to a GitHub repo, but I'm trying to use the command line now and I see this error:
remote: Permission to bfred-it/test.git denied to wildlifela.
wildlifela is a company account that I used recently on a different project, I think I only added my SSH key to that account.
The problem is that even after removing my key from that account (wildlifela), my account (bfred-it), the RSA keys from my computer (with ssh-add -D) and emptying the ~/.ssh folder, I still get that error.
It doesn't seem to be a repo issue: I just created a repo on GitHub.com, cloned it to my desktop, created a commit and git push origin master still produces that error.
After following the Generating SSH Keys procedure, ssh -T git#github.com authenticates me as bfred-it, but I still can't push as bfred-it.
What can I do?
(OSX 10.9)
I worked around this issue by using a different version of git.
Instead of using OS X's git I'm now using homebrew's git and it's working correctly.
If anyone has any insights as to what was happening, please share.
although i removed the ssh keys and the git config files from the OS, it just won't let me clone/pull/push to repositories
Check that the repo is indeed owned by you (for pushing to it)
There always is the option of using https url (with GitHub username/password)
removing the ssh key might not be enough, you also have the ~/.ssh/config file.
As mentioned in the comment, it can depend on your version of Git and on your OS (Windows, Mac or Linux).

Git fails initial push to new repo on network drive

Can you help me understand why my simple startup project is not working? I am using Windows XP, with Git installed from Git-1.8.1.2-preview20130201.exe. I am using Git Bash provided with the installation.
On the networked drive I do the following:
cd /k/repos
mkdir LV_Libraries.git
cd LV_Libraries.git
git init --bare
At my local copy of the project:
git init
git add *
git commit -m "Initial Commit"
git remote add origin /k/repos/LV_Libraries.git
git push origin master
The push fails saying,
"remote: error: unable to write sha1 filename ./objects/pack/pack-b69cd03c4c ... .pak: Permission denied"
"Remote: fatal: cannot store pack file"
"Error: unpack failed: index-pack abnormal exit"
"To k:/repos/LV_Libraries.git
! [remote rejected] master -> master (unpacker error)"
I initially thought it might be a file permissions thing, but I have no problems writing or reading files to the network drive through my terminal. Does anyone have any ideas?
Sounds like you are having problems similar to this question git: can't push (unpacker error) related to permission issues, i.e. permission problems on the k: disk, possibly related to user permissions.
Have you checked the exact permissions that you have on the UNC path for folder on K:?
I encountered this issue when attempting to push changes from a Windows machine via a Samba share hosted on a Mac OS X machine. I resolved this by initializing a SSH server on the Mac OS X machine and then cloning the project again via SSH on the Windows machine. Hence, all subsequent pushes from the Windows machine have worked beautifully without any errors.
When I checked out the project, via the Git GUI for Windows, I used the following syntax for the repository:
ssh://username#machost_ip:full_path_to_project
The username was the username used to create the project, the machost_ip was the IP address of my Mac OS X machine on my LAN, and the full_path_to_project was the fully qualified Unix path to the origin/master Git project.
I did not have success with the continued use of the shared drive even after changing group permissions. Although, I'm sure the username could be that of a user assigned to the group with write privileges to the project as specified in previous answers.
I deleted my git repository and then recreated it with
git init --bare --shared
and this solved the problem for me. Other answers mention setting config for shared and bare, but I found that only recreating the repository helped.
Have are your CRLF settings?
When playing around with the settings, I managed to generate a change that caused an problem identical to yours. In the end, I create a new clone of the remote repo and slowly merged my changes back to it.
I encountered same error yesterday. I am simply trying to clone one Big Git repository to my local windows machine using Git Bash 2.9.2.
After killing significant amount of time and reading above answers. I ran Git Bash as administrator and it worked like a charm. I am able to clone repository. Not sure what is the issue, I guess it is most probably related to permissions as many pointed.

Resources