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"
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.
Related
(Sorry for the unclear title). This is the scenario. I have a local server and I installed Gitstack in it. I was able to to push and pull to this local git server. This same server runs the webapp that I am working on. My plan is to push commits to this local git server and that change must also reflect to the webapp. So instead of using filezilla to copy files from my machine to serer, I will just push the changes via git. How to do it? Or is it possible?
I tried to look inside the Gitstack's installation folder. I expected to see the actual project's files inside but only git files are there.
My friends and I want to make a website using the CodeIgniter PHP framework. We rent a VPS which runs Cent OS 6.4.
As we developed the website, we met a problem: After user A changed something in var/www/application, A must inform B and C that he has changed something, and B and C must then download the new version and try to find out the difference between the new file and the old file (especially when this file had also been changed by B or C at the same time). We managed to use git to solve this problem. We installed gitolite in the server.
However, we now have another problem: after we push changes, we want to push the file directly into var/www/application, so we can test it directly in browsers.
My questions are,
Is it possible to push directly into var/www/application?
How can I do this?
how can I do this pushing with eclipse. I mean what kind of information should I put in the form below(I can't upload picture)
location
url:
host:
repository path:
user:
password:
It sounds like you're wanting to use Git for deployment. git push is what you use to push to a remote repo, not to some directory somewhere. What you really need is a script that does a git pull, and then possibly a git checkout to fetch the updated code from the repo, and switch to whatever branch you're using for deployment (unless you use master, then you can just stay on master all the time).
Depending on where you host your repo, you can set up a hook so that it will hit a URL on your server when new code is ready to grab.
I have a github account set up to my EC2 server with no issues. When i try to run a bash script to 'git pull' it wont do it. I will do a 'git status' and many other commands. Here is my sh file
cd /var/www/html/TDS/;
ls -la;
type git;
git status;
git remote -v;
git pull origin master;
echo "hello world";
All lines work except the git pull. I have tried git pull, git pull origin master, git fetch, git fetch origin master. I have ruled out all possibilities like permission issues and privileges.
This sh file is executed by hitting a PHP page, the PHP page looks like this
<?php
$output = shell_exec('/bin/sh /var/www/html/TDS/git.sh');
print_r("<pre>$output</pre>");
?>
Very simple and it works minus the Pull request. Any help would be amazing, I'm so close to getting this to work.
For a git pull to work, the user running it must have write permissions to the git repo's index (under .git/). Make sure the user under which the script is run (Apache?) has those rights.
...does PHP (www-data) have permissions? Is it the owner of the file?
Is this an ssh URL to the origin repository? Do you have ssh-agent running when you do it manually? Have you provided ssh agent access to the shell script (hint, the answers are Yes, Yes, No. Probably.)
So we have determined it is ssh access that is the problem. You then have two choices: getting ssh-agent credentials into the php process and allowing the php script access to ssh credentials without requiring a password. Both are problematic one way or another.
To get assh-agent credentials into the php process, copy the $SSH_AUTH_SOCK environmental variable from a shell into your php/shell script SSH_AUTH_SOCK=/tmp/ssh-wScioBA10361/agent.10361 git pull. Then assuming the php script has sufficient privs to access that file, git pull will work. This is problematic because you need to ssh into the system to get the auth sock, change the program to use the new socket (or write a program to find the current socket), and leave everything running. Log out, reboot, etc and you will lose git pull functionality.
The other option is to create ssh credentials for the php/shell user who is running git pull. Find the home directory, create .ssh, and ssh-keygen new keys for that user. You can set up the private key to not have a password so that anyone who can access this file (security risk!!) can ssh using those credentials. Add the public key to the authorized keys of the account who has access to the git repo (gitolite would allow you to restrict what privileges that account might have).
i can't figure out how i should access the repository from a CakePHP project called fredistrano (you can do CakePHP deploys with a web 2.0 interface). i have fredistrano in my web broadcasting directory on a shared unix web server. when i use tortoisesvn from my laptop, i have to use svn+ssh://username#domain.com/svnpath/trunk/. i tried using the same thing in fredistrano, but i keep getting the svn command error "svn: Network connection closed unexpectedly". i copied and pasted the command: svn export --non-interactive --username myusername --password mypwd svn+ssh://myusername#mydomain.com/home/myusername/svn/mydomain.com/trunk tmpDir 2>&1 into my SSH terminal connected to the shared server and i get a prompt for a password, which i believe is actual a prompt for the SSH password and not the SVN password (see this post). fredistrano is failing because it can't deal w/ the SSH password prompt. i noticed in the fredistrano documentation that the example uses http://ipaddress/svn/test for the SVN URL. i copied my svn to my web broadcasting direrctory and tried this but get a connection refused error. my shared hosting provider is pretty strict and i doubt that i can use that. is there a way i can get svn+ssh to work w/ a PHP script like this (fredistrano is just using shell_exec() to execute svn commands)? is there a way i can get just get svn, http, or https working (or any other method that i don't know about)?
I am interested in this problem, too, and I hope that I'm close to the solution.
I haven't tried to put it into work in my application due to the lack of time and other high-priority tasks, but I guess that it should look something like this:
shell_exec(svn something svn+ssh://...)
$response = trim(fgets(STDIN))
[then check if the response contains password prompt text]
fwrite(STDOUT, 'yourpassword');
[analyze the next response and see if SVN has returned the requested information - log, info, whatever]
"svn: Network connection closed unexpectedly" most probably means that your host has restricted/forbidden access to other hosts. This might imply using sockets at all (SVN, HTTP, etc.) or maybe only non-HTTP. In this case you should try setting up your SVN server to allow HTTP requests (e.g. using mod_dav_svn for Apache).
This is only a guess - see my comment to your question.
How do you authenticate from your dev machine to the svn-server? You might be using a key to authenticate (Do you have putty pageant running?)
maybe check out the Subversion PHP Module (1.0.3) instead of wrapping shell_exec; it requires building from source, with phpize, ./configure and make (just built it against PHP 5.6 and Subversion 1.9.5)... while the Apache Module mod_dav (Subversion via HTTP/HTTPS) is not required for version control, rather an optional method of accessing the repository.
Here is how our current php development solution is set up:
Each developer work on their local machine.
Each developer commit their change to a common SVN server (intranet).
A commit hook upload the change to the staging server and perform validations tasks.
When the product is ready, manually deploy it to the production server via SFTP.
Note: Most - if not all - of the time I don't have SSH access to the server, only SFTP.
I could automate the deployment to the production server in the same way the staging server is updated but this solution works only one-way. How can I revert to a previous revision in case of problems?
How can I improve this solution?
Thanks and sorry for my English.
If you can set up the production server to access the SVN repo via a secure channel, such as https with webdav maybe try the following:
Create a script on the Production server that allows you to enter a tag directory and/or revision number/date and perform an svn export. This way, the prod server is pulling the changes from svn.
Now, if you have a way to have this script called securely from, say a commit script. Voila, you have automation.
Most importantly, you do not want an automatic update performed to the prod server that you were not planning for.
To solve this:
The commit script should only call the prod update script when something is committed to "/path/to/tags/release/dir"
Make sure only appropriate change control staff (or whoever currently controls the manual prod deplyment) have the ability to perform an svn copy to this directory in the repo.
For example, say your repo is set up as:
/yourWebsite
--> /branches
--> /trunk
--> /tags
----> /releases
The commit that would trigger the auto deployment to prod would be something like:
svn copy https://mySvnRepo/yourWebSite/trunk \
https://mySvnRepo/yourWebSite/tags/releases/x.y \
-m "Tagging for production deployment"
Rolling back can be achieved by making a commit to a previous releases directory. Note however, that this will not cause new files that were added to be rolled back.
Of course, your mileage may vary; this is only a suggestion for your investigation.
You should take time to consider the security implications and potential for disaster if set up incorrectly.
Hope this helps, even if only to get you thinking of other solutions.