The following example uses IBM/Drain3 on Github as an example
Fork the target repository and clone it locally
$ git clone https://github.com/ieven/Drain3.git
Cloning into 'Drain3'. remote: Enumerating objects:231, done.
remote: Counting objects: 100% (231/231), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 565 (delta 132), reused 162 (delta 78), pack-reused 334
Receiving objects: 100% (565/565), 115.33 KiB | 299.00 KiB/s, done.
Resolving deltas: 100% (331/331), done.
Copy the code
$ cd Drain3/
Copy the code
Run git remote -v to check the path to your remote repository
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$ git remote -v
origin https://github.com/ieven/Drain3.git (fetch)
origin https://github.com/ieven/Drain3.git (push)
Copy the code
If only the above 2 lines indicate you have not set upstream. If so, skip the create upstream step below.
Create the upstream
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$ git remote add upstreamhttps://github.com/IBM/Drain3.git
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$ git remote -v
origin https://github.com/ieven/Drain3.git (fetch)
origin https://github.com/ieven/Drain3.git (push)
upstream https://github.com/IBM/Drain3.git (fetch)
upstream https://github.com/IBM/Drain3.git (push)
Copy the code
Git remote -v git remote -v git remote -v
Get updates from upstream
Run git fetch upstream to fetch the Drain3 repository update.
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$Git fetch upstream automatically synchronizes repository updatesCopy the code
Merge into the master branch of the local repository
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$Git checkout master iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$Git merge upstream/masterCopy the code
Push to its own remote repository
Git push pushes changes from the local repository to the Github repository (which you fork to yourself). Note that there are no additional arguments after Git push.
iEven@DESKTOP-OG5S6BE MINGW64 /d/try/Drain3 (master)
$Git push: Enter your password for git pushCopy the code
At this point your fork repository update is complete