I have a script that I would like to have do a git pull inside another user's git directory. This script is run by the root user. For example:
cd /home/username/GitProject
sudo -u username -i git pull
When I run this, I get:
fatal: Not a git repository (or any of the parent directories): .git
Is there a way to have my script do a git pull as username
?
Using the command lineGo into the directory for your project. Add a connection to your friend's version of the github repository, if you haven't already. Pull his/her changes. Push them back to your github repository.
On computer 1, clone the repo, create a branch, push your branch back to github. On computer 2, clone the repo, pull the branch you created down, make a change, and then push it back.
Try without the -i
option to sudo. That option is documented as first changing to the target user's home directory, which undoes the directory change you so carefully do before that. Alternatively, use the appropriate options to git to specify the directory, something like this:
sudo -u username -i git --git-dir=/home/username/GitProject/.git --work-tree=/home/username/GitProject pull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With