0

I am using a VM (homestead/laravel) to try to create a templated repository.

However although it all seemingly works fine but when it gets to pushing it never seems to recognize the remote.

fatal: No such remote 'origin'

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

The above are the 2 errors I typically get.

I have tried a few commands to set the remote.

git remote add origin https:://url.git - does not add the remote (checked git config)

git remote set-url origin https:://url.git - does not add the remote (checked git config)

git config remote.origin.url https:://url.git - sets url, but still does not work.

These are private repos, and I am using https with the user:pass to handle it since I cannot easily manage ssh keys with this setup (in other words I am forced to use HTTPS in this way).

After trying the commands through php I navigate to the directory in ssh and run the push. Works fine (if I use the third option above). I have used exec and https://github.com/kbjr/Git.php but both end up having the same issue.

Git version is: 2.7.2

PHP version is: 7.1.0

The only thought I have is that technically there is a git repo above the one generated. I am creating the repo in a temp folder in laravel and then generating the "template" before pushing it to a repo I create during the process (github api). Once its all done I delete it locally. However I don't see any errors that could be related to problems caused by "a repo under a repo"

7
  • 1
    can u exec pwd to confirm u r working on properly directory? Commented Dec 22, 2016 at 18:34
  • if u r working on the properly directory, u should check ur repository permissions and if your run user have permissions to run it.. Commented Dec 22, 2016 at 18:36
  • @gwdp I had thought that as well. I had provided full paths for all commands, also it is generating the git repo (git init) properly and it is doing it all from the same .sh file (getting executed from exec). For your second comment, the user does have permissions to the repo (pushing in ssh with the same remote works, but fails in php). Commented Dec 22, 2016 at 18:38
  • what echo shell_exec("cd /var/www/git-repo && /full/path/to/bin/git pull 2>&1"); will output? Commented Dec 22, 2016 at 18:42
  • .sh but "Git.php" uses them individually as well though it uses proc_open Commented Dec 22, 2016 at 18:43

1 Answer 1

1

Figured it out.

Ends up if you create a repo using the github API it does not actually create the repository before giving back the success response. So you need to force the script to wait before the push. In this case forcing it to wait 5 seconds (sleep(5);) seems to have resolved it.

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

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.