This is a small bash script I have written for syncing multiple modules that share dependancies and branch names.
- Modify the
projects
file in the project.- Create a new line for each repository on your system you wish to sync.
- Path must be absolute:
/path/from/root/to/project/
- Lines starting with # are ignored in the projects file.
- You probably need to give syncb executable privledges.
sudo chmod +x syncb
- Create an alias and environment variable your shell's configuration file i.e.
.bashrc
or.zshrc
- Example:
export SYNCB_HOME=~/projects/fork-sync/
- Example:
alias syncb="~/projects/fork-sync/syncb"
- You can skip this part and run the script directly if you want.
- Example:
- Thats all you need!
- You have to have git CLI installed. (duh)
- This script assumes
upstream
is set to the original remote respository. (The repo you forked) - This script assumes
origin
is set to the remote fork respository. (Your remote fork)
> syncb {branchName}
The script will iterate over each project listed in the projects
file.
- Stash any current changes.
- Fetch from origin and upstream.
- Checkout the specified branch from origin, if it doesn't exist, upstream
- If its unable to checkout, script will stop for that project, pop stash, and move on.
- Pull any changes from the upstream repository.
- Push any new changes from upstream to origin.
- Pop the stash, leaving your uncommitted changes back the way they were! (Unless they conflict with new changes).