I want to run something in the background which basically does a git pull --rebase
whenever some changes happen in my remote branch. Most of the time it work silently in the background if there are no conflicts. In there is a conflict it just leaves me in the rebase-resolve-conflict stage and until I resolve everything it waits. How do I do this? Is there an existing software that already does this?
If you want to have a working tree on a remote machine that you push to you can either run 'bzr update' in the remote branch after each push, or use some other method to update the tree during the push. There is an 'rspush' plugin that will update the working tree using rsync as well as doing a push.
git fetch is used in conjunction with git remote , git branch , git checkout , and git reset to update a local repository to the state of a remote. The git fetch command is a critical piece of collaborative git work flows.
If you don't have control on the remote repository, one solution is to use crontab to run periodically git fetch
or maybe even a git pull --rebase
as you propose. The exact command to choose depends on your workflow, personally I prefer to use a git fetch
because I can decide when and how to merge or rebase.
To run the command periodically run:
crontab -e
And add a line such as:
* * * * * git -C PATH_TO_LOCAL_REPO fetch
or
* * * * * git -C PATH_TO_LOCAL_REPO pull --rebase
This will run the git command every minutes with your user permissions.
If you want to apply the git command on a list of repository, you can can add the line:
* * * * * /home/myself/scripts/git-refresh.sh
where git-refresh is a script that apply on all your repositories.
The -C
option allows you to run a git command without changing directory. From the man page:
-C <path>
Run as if git was started in "path" instead of the current working directory.
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