Skip to content

Syncing a fork

Fabien Spindler edited this page Oct 20, 2015 · 2 revisions

Syncing a fork

How to sync a fork of a repository to keep it up-to-date with the upstream repository is explained here. We recap hereafter the instructions.

Configuring a remote for a fork

To [sync changes you make in a fork](# Syncing a fork of ViSP) with the original repository, you must first configure a remote that points to the upstream repository in Git.

  1. Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).

  2. List the current configured remote repository for your fork.

    $ git remote -v
    origin	https://github.com/YOUR_USERNAME/visp.git (fetch)
    origin	https://github.com/YOUR_USERNAME/visp.git (push)
    
  3. Specify a new remote upstream repository that will be synced with the fork.

    $ git remote add upstream https://github.com/lagadic/visp.git
    
  4. Verify the new upstream repository you've specified for your fork.

    $ git remote -v
    origin	https://github.com/YOUR_USERNAME/visp.git (fetch)
    origin	https://github.com/YOUR_USERNAME/visp.git (push)
    upstream	https://github.com/lagadic/visp.git (fetch)
    upstream	https://github.com/lagadic/visp.git (push)
    

Syncing a fork of ViSP

  1. Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).

  2. Change the current working directory to your local project.

  3. Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.

    $ git fetch upstream
    remote: Counting objects: 57, done.
    remote: Compressing objects: 100% (47/47), done.
    remote: Total 57 (delta 22), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (57/57), done.
    From https://github.com/lagadic/visp
     * [new branch]      master     -> upstream/master
    
  4. Check out your fork's local master branch.

    $ git checkout master
    
  5. Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.

    $ git merge upstream/master
    Updating 67afb0d..fc31b59
    Fast-forward
     modules/core/include/visp3/core/vpHistogram.h    |  52 ++++++++++---
     modules/core/include/visp3/core/vpImage.h        |  48 ++++++++++++
     modules/core/include/visp3/core/vpMath.h         | 144 +++++++++++++++++++++++++++++++++++-
     modules/core/src/tools/histogram/vpHistogram.cpp |  81 ++++++++++++++++++--
     modules/core/test/math/testMath.cpp              | 288 +++++++++++++++++++++++++++++++++++++++++++++++-
     5 files changed, 591 insertions(+), 22 deletions(-)
    
  6. To update your fork on GitHub, you must push your changes.

    $ git push