New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Git post-receive not working as expected ?
Hi, I am trying to publish to a remote git repo. On local I have added it as , say call it web-app which should publish to remote "master" branch from a local branch named "public"
Now issue is that whenever push as following then it is publishing to "public" branch on remote repo while I want it to be on "master'.
git push web-app public
I have following in post-receive hook:
#! /bin/sh
GIT_WORK_TREE=/path/to/remote/web/app git checkout -qf master
short version:
how to make sure that any local git branch is synced / pushed to remote "master" always.
Comments
Have you remembered to chmod a+rx
post-receive
? Is it definitely in the repo's hooks directory? Are you running the repo as a different user? Maybe you don't have permission to write to the directory you're checking out to. Maybe git isn't in your default path.FWIW, I do something similar in my repo, but instead of doing stuff in there directly (which would slow down every push to the repo), I instead just leave a marker somewhere (especially as I run my git as an isolated user using gitolite):
Then I have a crontab as my own user which kicks off a build on a different build machine by running this script every minute:
Oh, and of course
/home/ralf/.blah-build
has permissionsdrwxrwxr-x
and chown'd to ralf:git, so that the git user can write into it.This way is good for debugging, as you can watch the directory to see the file being created, and also manually trigger a build by creating the empty file yourself.
I am not power user of git, just enough to fulfill my need, were using locally, now wanted to use remote and facing problem I mentioned.
git push origin master, but you have to set up the correct direction before.
Oh, you're trying to push to a remote repo? Then you're only doing half of the thing.
You confused my by calling it web-app and doing a checkout to a different work tree, so it looked like you were trying to deploy the branch onto a web server.
So, I mean, the easiest way is just
git push web-app localbranch:master
This pushes localbranch to web-app's branch called master.
So, this is pushing the local branch public to web-app's branch called public.
And this is checking out the branch called master to some random directory. This is your problem. If you want the public branch in that directory, change master to public.
If what you want is for your repo to push the latest branch to another repo called master, you can do that. Then, it'd look like mine.
This will force a push to this repo on any branch to be pushed to the branch master on another_repo.
I'm still not sure this is what you want, it sounds a bit crazy to me. Maybe you just want:
This is a different question again to what you're asking. It also sounds very much NOT like what you want to do, because it would mean you could never have a temporary branch where you're working on things because any push to any branch would change master.
I'd advise you to manually do what I suggested at the top of this post:
git push web-app localbranch:master
Is your profile picture AI generated?
Oh man, sorry for the confusion, I am not well-versed with git, just know it enough to find my way around but your explanation is quite helpful, I just wanted this one
git push web-app localbranch:master