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

  • Home
  • SEARCH
  • 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 8923983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:16:47+00:00 2026-06-15T07:16:47+00:00

On the server I have bare repository which is origin for development process and

  • 0

On the server I have bare repository which is origin for development process and to simplify deployment to QA environment.

So in post-receive it simply does

GIT_WORK_TREE=/home/dev git checkout -f

But as product gets more complicated there are some other things should be happening. So now it is handled by deploy.sh script which is also tracked by repository. So what I want to do is to be able instead of checking out whole repository is to checkout only deploy.sh and run it. I thought something like that would work:

SOURCE_PATH="/home/dev"
GIT_WORK_TREE=$SOURCE_PATH git checkout deploy.sh
$SOURCE_PATH"/deploy.sh"

But it does not work giving error:

error: pathspec 'deploy.sh' did not match any file(s) known to git.

What am I doing wrong? Or is it just impossible to do this way?

  • 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-06-15T07:16:49+00:00Added an answer on June 15, 2026 at 7:16 am

    As I explain in “checkout only one file from git“, you cannot checkout just one file without cloning or fetching first.

    But you git show that file, which means you can dump its content into a /another/path./deploy.sh file, and execute that file.

    git-show HEAD:full/repo/path/to/deploy.sh > /another/path./deploy.sh
    /another/path./deploy.sh
    

    Since you execute that from a post-receive hook, the git-show will show the latest version of the deploy.sh file.


    The other alternative would be try

     GIT_WORK_TREE=$SOURCE_PATH git checkout -- path/to/deploy.sh
    

    And checkout only that file, directly in your working tree.

    The ‘--‘ help the git command to understand it is a file, not another parameter like a tag or a named branch.

    From the OP AlexKey‘s test, it requires that the working tree has been checked out (fully) at least once.

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

Sidebar

Related Questions

I have a bare repository on my home-server to which I push from my
I have a remote server on which I have created a bare git repository.
I have this simple hook on /hooks/post-update inside a bare repository: #!/bin/sh git-update-server-info GIT_WORK_TREE=/home/user/apps/application-site/dev
I have a bare repository on my server that I push to in /var/www/repos/my_project
We have a bare repository on a remote server that people can connect to
When pushing to our shared bare repository (over ssh), the post-commit does not work
I have a bare-bones install of jenkins on my Ubuntu server that I installed
Does each column of a table in SQL Server have a unique id? I've
I have a client-server Silverlight application, which is use Socets. I have server appliaction
I have a bare repository at /home/dan/repo/ and a working copy at /home/dan/www/project/ .

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.