Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7660257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:26:28+00:00 2026-05-31T13:26:28+00:00

Up until today I was using git in the following manner: a master repo

  • 0

Up until today I was using git in the following manner:

  • a master repo /path/www on my webserver as the document root

  • a clone on my PC

I normally made large changes on the PC and pushed to the server. After doing this, I had to “git reset HEAD” and “git checkout .” on the server. Sometimes I would make a small change on the server and pull this back to the PC. This all worked fine until today when, on pushing, git complained

remote: error: refusing to update checked out branch: refs/heads/master
etc.  

Why, after 6-12 months working fine, should this fail now?

After finding http://toroid.org/ams/git-website-howto thanks to a StackOverflow question, I copied /path/www to /path/www.git and made this a ‘bare’ repo. The document root remains at /path/www. I added a .git/hooks/post-receive script containing “GIT_WORK_TREE=/path/www checkout -f”.

After modifying the config on the PC to point to the http://www.git repo, I can now push as before and the changes get uploaded and updated in the document root. I have a few questions about this:

  • the howto implies that the working tree has no .git metadata. Is this really so? I tried removing its .git directory but “git status” no longer worked. Setting GIT_DIR to /path/www.git did not help as git said the repo (the bare one at /path/www.git) was not in fact a repo.

  • If I update index.html and add somefile.html on the PC and push these changes, these files are updated/added-to in the server’s doc root. But if I use “git status” in the doc root, it tells me that index.html has been changed and somefile.html is an untracked file. I naively expected that the “checkout -f” would have updated the working tree to exactly what I pushed from the PC. Can I achieve that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:26:29+00:00Added an answer on May 31, 2026 at 1:26 pm

    the howto implies that the working tree has no .git metadata. Is this
    really so?

    Yes. You have a bare repo setup and to actually get your files for your website, you “temporarily” assign a working directory to the bare repo and check it out to the website path that you want. That is what GIT_WORK_TREE=/path/www checkout -f does. The .git that was present would have been an artifact of your previous setup before you moved to the bare repo.

    But if I use “git status” in the doc root, it tells me that
    index.html has been changed and somefile.html is an untracked file.

    Again, this seem like the effect of the presence of the .git from your previous setup. Delete the /var/www/.git

    I naively expected that the “checkout -f” would have updated the
    working tree to exactly what I pushed from the PC.

    Your expectation is right and this how it is supposed to work. Remove the .git as mentioned above.

    To actually do a git status, go to /var/www.git and do GIT_WORK_TREE=/var/www git status

    PS: Why are you doing so many changes and git status on your server? Limit yourself to your PC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Up until today I've been able to run queries without using the [databaseName].[dbo].[fieldName] syntax.
Until yesterday everything was normal but today i try to lauch my application using
Have a have a Windows VPS using Plesk 9. Until today I have been
This is literally my first day using PHP. I've never seen it until today,
I am using my new mac for the first time today. I am following
Until today I was living under the impression that RSA encryption using RSA is
I've been using a vanilla apache install until recently with no major problems. Today
I have never used DBIx::Class until today, so I'm completely new at it. I'm
I want to select data between 1 week ago data until today data: SELECT
My IDE has been working very well, until today. When I try to compile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.