Description
git-sync
is used for syncing a personal fork with the upstream repository the personal fork was created from. Syncing here means updating all the branches in the personal fork that are also present in the upstream repository. git-sync
will by default only update the branches in the remote repository for your personal fork (i.e. your local repository on disk will remain unchanged). git-sync
can sync both the personal fork and a local repository of the personal fork, see the Examples section that involves the flags --ff
and --pull
.
git-sync uses multiple strategies to figure out the repository to sync from (i.e. the repository the personal fork was created from):
- If the --from option is defined via either configuration or command-line
- If a remote named upstream is present for the repository
- If it can connect via REST HTTP APIs for the current forge
The repository to sync to will by default be the repository that the remote named "origin" refers to.
Usage
$ git sync -h usage: git sync [options] --from REMOTE Fetch changes from this remote --to REMOTE Push changes to this remote --branches BRANCHES Comma separated list of branches to sync -u, --username NAME Username on forge --pull Pull current branch from origin after successful sync -ff, --fast-forward Fast forward all local branches where possible --verbose Turn on verbose output --debug Turn on debugging output -v, --version Print the version of this tool -h, --help Show this help text
Examples
Sync a personal fork and explicitly set both the from and to repository:
$ git sync --from https://github.com/openjdk/jdk --to git@github.com:edvbld/jdk.git
Add a remote named "upstream" and rely on git-sync to by default pick up the remote named "origin" for the to option:
$ git remote add upstream https://github.com/openjdk/jdk $ git sync
Sync a personal fork (relying on "upstream" and "origin" remotes being present) and also pull the latest changes for current active branch from your personal fork:
$ git sync --pull
Sync a personal fork (relying on "upstream" and "origin" remotes being present) and also fast-forward all branches in the local repository:
$ git sync -ff
Configuration
All options to git-sync
can be configured via git-config
. For example, to make git-sync
always fast-forward all branches in the local repository when syncing, set sync.ff
to true
:
$ git configure --global sync.ff true