Pushing and existing project into bare repo
I've been working on a project locally using git and laravel. I've finally decided to add a bare repo to our server in order to push the changes and automate deployment.
I'm sure I'm doing something wrong as I'm green to using git. When I do a push I get the following error:
stdin: is not a tty bash: git-receive-pack: command not found fatal: Could not read from remote repository Please make sure you have the correct access rights and the repository exists.
Here's the process I used - keep in mind the project repository was initially cloned from laravel and I created my own master branch and a few pushes exist. I also have all ssh logging setup already.
- logged in via ssh
- created directory: mkdir public_html.git
- changed directory: cd public_html.git
- created the repo: git init --bare
- added a post-receive hook - which i verified works in a test project
- moved back to local machine
- added a new remote: git remote add www email@example.com:public_html.git
- made a new branch: git checkout -b develop
- attempted to push: git push www
Most of the research from looking into this mentions checking the git/config file, but all of that seems to be correct.
It looks like git-receive-pack is not on the path for the user configuration used to push to the repository. When you push to a git repository via ssh git will use ssh to execute commands on the remote server under the user account which is doing the push. These commands, such as git-receive-pack, must be available on that user's path on the server. To diagnose this I would start by executing the command
ssh firstname.lastname@example.org which git-receive-pack
You will almost certainly get a command not found error. Next you could try
ssh email@example.com 'echo $path' # Note the single quotes.
This will show you what the user's path is on the remote server and may help you figure out what is wrong. Note the line in the ssh man page:
ssh ... [user@]hostname [command]
If command is specified, it is executed on the remote host instead of a login shell.
This can be a subtle but important distinction as it means a login shell to the remote created with ssh firstname.lastname@example.org may not see the same shell environment as a command run by ssh email@example.com some remote command. This answer has an explanation of how this works for the bash shell, others behave similarly.