Git - Fork (Upstream)

> Code - (Programming|Computer) Language > Code Versioning > Git

1 - About

A fork is the copy of a repository.

The orginal repository of a fork is known as the upstream. It's a remote branch.

same as Git - Upstream Branch

Advertising

3 - Management

3.1 - Add an upstream

see Git - Upstream Branch

git remote add upstream url_repo
 
## For instance
git remote add upstream https://github.com/user/repo

3.2 - Sync

To sync your local repo with the upstream, you can

  • Pull: If you don't have push (write) access to an upstream repository

3.2.1 - Merge

Sync a fork of a repository to keep it up-to-date with the upstream repository.

  • Fetch the upstream fetch will update the branch (commits history, …)
git fetch upstream
  • Go to the master branch
git checkout master
  • Merge the upstream with the actif branch (ie master)
git merge upstream/master
Merge made by the 'recursive' strategy.
 lang/no/lang.php     | 4 +++-
 lang/no/move.txt     | 7 +++++--
 lang/no/settings.php | 6 ++++--
 lang/no/tree.txt     | 2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)
Advertising

3.2.2 - Pull

If you don't have push (write) access to an upstream repository, then you can pull commits from that repository into your own fork

  • Go to master
git checkout master
cd fork
git pull https://.../UpStreamrepo.git branch
# Example
git pull https://github.com/michitux/dokuwiki-plugin-move.git master
remote: Counting objects: 85, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 85 (delta 48), reused 41 (delta 41), pack-reused 14
Unpacking objects: 100% (85/85), done.
From https://github.com/michitux/dokuwiki-plugin-move
 * branch            master     -> FETCH_HEAD
Auto-merging lang/en/lang.php
Merge made by the 'recursive' strategy.
 README                 |  26 +++++++++-
 _test/handler.test.php |  13 ++++-
 action/rename.php      |  23 ++++-----
 admin/tree.php         |  20 +++++---
 conf/default.php       |   1 +
 conf/metadata.php      |   1 +
 helper/handler.php     |  15 ++++--
 helper/rewrite.php     |   4 +-
 images/folder_add.png  | Bin 0 -> 668 bytes
 lang/de/lang.php       |   2 +-
 lang/de/settings.php   |   3 +-
 lang/en/lang.php       |   1 +
 lang/en/settings.php   |   1 +
 lang/ja/lang.php       |   3 +-
 lang/ja/settings.php   |   3 +-
 plugin.info.txt        |   2 +-
 script/tree.js         | 129 +++++++++++++++++++++++++++++++++++++------------
 style.less             |   4 +-
 18 files changed, 185 insertions(+), 66 deletions(-)
 create mode 100644 images/folder_add.png
  • Commit and push

4 - Documentation / Reference

code/version/git/remote_fork.txt · Last modified: 2019/03/04 20:58 by gerardnico