Chinaunix首页 | 论坛 | 博客
  • 博客访问: 728313
  • 博文数量: 130
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2198
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-29 12:48
个人简介

每一个“丑得人神共愤”的泡妞高 手都有一颗坚忍的心,这证明了人类 在绝境中毫不妥协的求生精神,反正丑都丑了,索性放开手脚大干一场,这就叫“无产阶级失去的是锁链,得到的是全世界”

文章分类

全部博文(130)

文章存档

2013年(130)

我的朋友

分类: LINUX

2013-10-09 10:38:39


Syncing a fork
The Setup

Before you can sync, you need to add a remote that points to the upstream repository. You may have done this when you originally forked.

Tip: Syncing your fork only updates your local copy of the repository; it does not update your repository on GitHub.

git remote -v
# List the current remotes
# origin  (fetch)
# origin  (push)

git remote add upstream
# Set a new remote

git remote -v
# Verify new remote
# origin    (fetch)
# origin    (push)
# upstream  (fetch)
# upstream  (push)

Syncing

There are two steps required to sync your repository with the upstream: first you must fetch from the remote, then you must merge the desired branch into your local branch.
Fetching

Fetching from the remote repository will bring in its branches and their respective commits. These are stored in your local repository under special branches.

git fetch upstream
# Grab the upstream remote's branches
# remote: Counting objects: 75, done.
# remote: Compressing objects: 100% (53/53), done.
# remote: Total 62 (delta 27), reused 44 (delta 9)
# Unpacking objects: 100% (62/62), done.
# From
#  * [new branch]      master     -> upstream/master

We now have the upstream's master branch stored in a local branch, upstream/master

git branch -va
# List all local and remote-tracking branches
# * master                  a422352 My local commit
#   remotes/origin/HEAD     -> origin/master
#   remotes/origin/master   a422352 My local commit
#   remotes/upstream/master 5fdff0f Some upstream commit

Merging

Now that we have fetched the upstream repository, we want to merge its changes into our local branch. This will bring that branch into sync with the upstream, without losing our local changes.

git checkout master
# Check out our local master branch
# Switched to branch 'master'

git merge upstream/master
# Merge upstream's master into our own
# Updating a422352..5fdff0f
# Fast-forward
#  README                    |    9 -------
#  README.md                 |    7 ++++++
#  2 files changed, 7 insertions(+), 9 deletions(-)
#  delete mode 100644 README
#  create mode 100644 README.md

If your local branch didn't have any unique commits, git will instead perform a "fast-forward":

git merge upstream/master
# Updating 34e91da..16c56ad
# Fast-forward
#  README.md                 |    5 +++--
#  1 file changed, 3 insertions(+), 2 deletions(-)


阅读(1773) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~