I have several non-bare Git repositories. There is one central Git repository (or at least handled as being the central repo; this might change) but this is also non-bare (because I want to have a checkout on the same machine). My history is mostly linear and I'm the only person who will ever do changes on this repository, so it is unlikely that conflicts will happen. (It is my documents directory.)
Pushing directly into another non-bare repository doesn't work if I use the master
branch everywhere. There is receive.denyCurrentBranch
which would allow this but it doesn't really help me because (1) it doesn't update the local checkout and (2) I'm afraid of what happens in case there is a conflict.
There are a few related/similar questions here:
- simplest way to sync a repository with a checked out branch: Suggests setting up an Bash alias (basically
ssh git pull
). - making pushes to non-bare repositories safe: Using a
post-update
hook (with a strong advise to avoid it). Or rather push it to some specific unique remote ref and let the destination later handle the merging.
I want a solution which is 100% safe. So I think using a post-update
hook is no option for me.
I think my use case is not actual that uncommon so I wonder if there are some common solutions for this. Are there?
I think, what I want is:
- Push local
master
to some remote special ref (likemerge-request-xy
) (i.e. likegit push origin master:merge-request
?). - On the remote, if we can fast-forward and the working copy is clean, fast-forward, update the working copy and delete the ref (basically
git merge merge-request && git branch -D merge-request
?).
Would that be safe or a good way to do it?