场景
实际工作可能需要fork别人的代码另做开发,但是又有需求希望同步源仓库的更新。以下实例将演示如何同步源仓库代码。
Mac, Linux, windows通用
1 2 3 4 5 6 7 8 9
   | blockchain git:(f03d28f) ✗ git remote -v origin	https://github.com/dvf/blockchain (fetch) origin	https://github.com/dvf/blockchain (push) blockchain git:(f03d28f) ✗ git remote add upstream https://github.com/dvf/blockchain blockchain git:(f03d28f) ✗ git remote -v origin	https://github.com/dvf/blockchain (fetch) origin	https://github.com/dvf/blockchain (push) upstream	https://github.com/dvf/blockchain (fetch) upstream	https://github.com/dvf/blockchain (push)
   | 
 
1 2 3 4 5 6 7 8 9
   | blockchain git:(f03d28f) ✗ git fetch upstream remote: Counting objects: 77, done. remote: Total 77 (delta 23), reused 24 (delta 23), pack-reused 53 Unpacking objects: 100% (77/77), done. From https://github.com/dvf/blockchain  [new branch]      dvf/bug-fix  -> upstream/dvf/bug-fix  [new branch]      dvf/hash-fix -> upstream/dvf/hash-fix  [new branch]      dvf/tests    -> upstream/dvf/tests  [new branch]      master       -> upstream/master
   | 
 
1 2 3 4
   | blockchain git:(f03d28f) ✗ git checkout master M	blockchain.py Switched to branch 'master' Your branch is up-to-date with 'origin/master'.
   | 
 
- 合并upstream/master到local master
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
   | blockchain git:(master) git merge upstream/master Updating f03d28f..4010cf3 Fast-forward  .gitattributes                                       |  63 +++++++++++++++  .travis.yml                                          |  12 +++  README.md                                            |   2 +  blockchain.py                                        |  22 +++---  csharp/BlockChain.Console/App.config                 |  10 +++  csharp/BlockChain.Console/BlockChain.Console.csproj  |  63 +++++++++++++++  csharp/BlockChain.Console/Program.cs                 |  12 +++  csharp/BlockChain.Console/Properties/AssemblyInfo.cs |  36 +++++++++  csharp/BlockChain.sln                                |  43 ++++++++++  csharp/BlockChain/Block.cs                           |  19 +++++  csharp/BlockChain/BlockChain.cs                      | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++  csharp/BlockChain/BlockChain.csproj                  |  73 +++++++++++++++++  csharp/BlockChain/Node.cs                            |   9 +++  csharp/BlockChain/Properties/AssemblyInfo.cs         |  36 +++++++++  csharp/BlockChain/Transaction.cs                     |   9 +++  csharp/BlockChain/WebServer.cs                       |  78 ++++++++++++++++++  csharp/BlockChain/packages.config                    |   5 ++  tests/__init__.py                                    |   0  tests/test_blockchain.py                             | 104 ++++++++++++++++++++++++  19 files changed, 811 insertions(+), 11 deletions(-)  create mode 100644 .gitattributes  create mode 100644 .travis.yml  create mode 100644 csharp/BlockChain.Console/App.config  create mode 100644 csharp/BlockChain.Console/BlockChain.Console.csproj  create mode 100644 csharp/BlockChain.Console/Program.cs  create mode 100644 csharp/BlockChain.Console/Properties/AssemblyInfo.cs  create mode 100644 csharp/BlockChain.sln  create mode 100644 csharp/BlockChain/Block.cs  create mode 100644 csharp/BlockChain/BlockChain.cs  create mode 100644 csharp/BlockChain/BlockChain.csproj  create mode 100644 csharp/BlockChain/Node.cs  create mode 100644 csharp/BlockChain/Properties/AssemblyInfo.cs  create mode 100644 csharp/BlockChain/Transaction.cs  create mode 100644 csharp/BlockChain/WebServer.cs  create mode 100644 csharp/BlockChain/packages.config  create mode 100644 tests/__init__.py  create mode 100644 tests/test_blockchain.py
   | 
 
