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 7710115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:02:09+00:00 2026-06-01T01:02:09+00:00

I am trying to git pull some repository via root user from any directory.

  • 0

I am trying to git pull some repository via root user from any directory.

For example, executing git pull from /root/:

#> cd ~
#> sudo -u dmalikov git --git-dir=/home/dmalikov/path/to/repo/.git pull 
/usr/libexec/git-core/git-sh-setup: line 142: cd: /root/.: Permission denied
Cannot chdir to /root/., the toplevel of the working tree

And executing git pull from /:

#> cd /
#> sudo -u dmalikov git --git-dir=/home/dmalikov/path/to/repo/.git pull 
Already up-to-date.

Why did current directory affects git pulling command?

How can that redundant cd be avoided?

  • 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-01T01:02:12+00:00Added an answer on June 1, 2026 at 1:02 am

    In your first example, the git command runs as user dmalikov with the current directory /root. Since the git pull command is equivalent to a git fetch followed by a git merge, and since git merge operates on the working tree, git tries to hunt for the working tree. As this user does not have permission to cd /root, the git command fails.

    Even your second example doesn’t work as you would expect. If there are actual changes to be pulled (instead of “Already up-to-date”), then the git pull will fail because it can’t find the working tree.

    You have a few simple options:

    1) You can just do the git fetch portion of the operation by doing:

    sudo -u dmalikov git --git-dir=/home/dmalikov/path/to/repo/.git fetch
    

    which doesn’t give any error for me.

    2) You can add a cd to the working tree:

    (cd /home/dmalikov/path/to/repo; sudo -u dmalikov git pull)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run git from a different directory than I am in.
Trying to perform a pull from a remote repository, however the relevant code is
I am looking for some advise with git and push / pull and trying
I'm trying to do a ' hg convert ', to pull from a Git
I am trying to do a 'git pull --rebase', but I don't see any
I am trying to pull from my heroku remote, I get this message: >git
I'm trying to pull from a repository which has about 10 files. On my
I am trying to pull or clone a git repo from my joyent smartmachine
I'm trying to use git on windows to clone a remote repository. I can
I'm a Git user trying to use Mercurial. Here's what happened: I did a

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.