git学习 - 把原作者的代码更新到本地

假如我们fork了别人的代码,过了一段时间之后,我们需要先获取原作者的代码到本地。

我们可以先看下都有什么远程仓库。提交给原作者代码的方法我在上面的博客里有说(传送门:http://blog.csdn.net/alps1992/article/details/38548107)


然后查看 git remote -v:

➜ /Users/alps/Sites/zhaonong/html git:(master) ✗>git remote -v
origin	https://github.com/chenfushan/zhaonong (fetch)
origin	https://github.com/chenfushan/zhaonong (push)
upstream	https://github.com/Fanset/zhaonong (fetch)
upstream	https://github.com/Fanset/zhaonong (push)


我们可以看到我这里有两个远程哭,origin是我的远程仓库,upstream是我fork的源地址。


然后我们可以拉取upstream的代码到本地

 /Users/alps/Sites/zhaonong git:(master) ✗>git pull upstream master
From https://github.com/Fanset/zhaonong
 * branch            master     -> FETCH_HEAD
Updating e3ac498..b4c0b21
Fast-forward
 README.md                  |    6 +
 css/style.css              |   45 +
 html/.DS_Store             |  Bin 6148 -> 0 bytes
 html/address.html          |   90 +-
 html/goodspage.html        |   25 +-
 html/list_of_economic.html |   19 +-
 html/list_of_gift.html     |    7 +-
 html/list_of_portable.html |   14 +-
 html/management_ad.html    |    0
 html/management_pd.html    |    0
 html/order_commit.html     |   73 +-
 html/orderpage.html        |   23 +-
 html/undefined.html        |   11 +-
 image/.DS_Store            |  Bin 6148 -> 0 bytes
 js/getUrl.js               |   16 +-
 js/getcookie.js            |   16 +
 js/goodspage.js            |    6 +-
 js/jquery-2.1.1.js         | 9190 --------------------------------------------
 18 files changed, 214 insertions(+), 9327 deletions(-)
 create mode 100644 README.md
 create mode 100644 css/style.css
 delete mode 100644 html/.DS_Store
 create mode 100644 html/management_ad.html
 create mode 100644 html/management_pd.html
 delete mode 100644 image/.DS_Store
 create mode 100644 js/getcookie.js
 delete mode 100644 js/jquery-2.1.1.js

然后
git merge master
这个可能不需要。

假如现在是在master的分支上的话。

➜ /Users/alps/Sites/zhaonong git:(master) ✗>git push origin master
Counting objects: 81, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (60/60), done.
Writing objects: 100% (61/61), 7.54 KiB | 0 bytes/s, done.
Total 61 (delta 43), reused 0 (delta 0)
To https://github.com/chenfushan/zhaonong
   e3ac498..b4c0b21  master -> master

然后现在就把所有代码同步了。




你可能感兴趣的:(git,branch)