Git - Fork (Upstream)

About

A fork is an entire copy of a repository.

The original repository of a fork is known as the upstream repository.

It has the same concept as a upstream branch.

Management

Add an upstream

see Git - Upstream Branch (Tracking branch)

git remote add upstream url_repo

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

Sync

To sync your local repo with the upstream, you can

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

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(-)

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

Documentation / Reference





Discover More
Commit History Forked
Git - Forked commit management

This is a page a local fork (ie a local branch). remote fork To incorporate the new commits into your feature branch, you have two options: merging or rebasing. Forked commit history
Git - Merge

Merge is a git merge tool that is designed to integrate changes from one branch into another branch It joins two or more branch together (ie development histories) The pull command is a wrapper that...
Git - Remote (Tracked Repository)

A remote in Git is a remote repository (ie a remote git server). Git remote manage the set of repositories (“remotes”) whose branches you track. They are also called tracked repositories in reference...
Branches Git
Git - Branch

This page talks Branch management in Git. For Git, a branch is: a commit name (ref) that points to the last commit (head) leaf in the commit log (or log) that represents a commit chain Example...



Share this page:
Follow us:
Task Runner