Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Copying the answer straight from the <a href="https://stackoverflow.com/questions/5703324/cannot-git-clone-a-folder-on-a-server-and-then-edit-and-git-push">related question</a> where you already got it:</p> <p>You have two options:</p> <ol> <li><p>Make a bare repository (<code>mysite.com.git</code>) and a non-bare repository (<code>mysite.com</code>). In the bare repository, add a <code>post-update</code> hook to <code>git --git-dir=.../mysite.com pull</code></p> <p>Note, that you may want to create the non-bare repository by cloning from the bare one with <code>-s</code> flag or set up <code>.git/objects/info/alternates</code> afterwards to avoid copying all the data.</p></li> <li><p>Make just one repository and:</p> <ol> <li><p>Detach the head: <code>git checkout master@{0}</code></p></li> <li><p>Add a <code>post-update</code> hook to <code>git merge master</code></p></li> </ol> <p>The reason here is that git refuses to modify the checked-out branch, but if you uncheckout the branch, you will be able to push. And you will be able to update the working directory from a hook (hook is a script placed in <code>hooks</code> directory in the repository). You can either create a separate branch and check out that, or you can use the "detached HEAD" state (as suggested above&mdash;git remembers which branch is checked out by having a special reference "HEAD" that points to the branch, but if you check out something, that is not a branch, it is made to point to a revision directly and that's called a "detached branch" and since no branch is checked out, allows you to push to any of them).</p></li> <li><p>Make just one repository and:</p> <ol> <li><p>Turn off the push-to-checked-out-branch check.</p></li> <li><p>Add a <code>post-update</code> hook to <code>git reset --hard</code> to re-checkout the branch when pushed.</p></li> </ol> <p>This option is only valid for read-only access, because the hook will discard any local changes each time you push.</p></li> </ol> <p>If it's just check out and have it accessed read-only, the second option is slightly more efficient, but if you run some other commands on the working directory, the first is safer (you can wipe and re-create the working copy without worrying about the main repo). See also <a href="https://stackoverflow.com/questions/5219975/git-remote-for-testing">this question</a>.</p> <p><strong>Edit:</strong> added third option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload