常用操作一
同步 Github fork 出来的分支 (更新代码仓库)
- 解决方案:项目先 fetch 到本地,再通过命令行的方式 merge 到自己的线上仓库
- #1 跟上游仓库同步代码之前,必须配置过 remote,指向上游仓库 。
- #2 从上游仓库获取到分支( git fetch ),及相关的提交信息,它们将被保存在本地的 upstream/master 分支
- #3 切换到本地的 master 分支
- #4 把 upstream/master 分支合并到本地的 master 分支,本地的 master 分支便跟上游仓库同步,并且没有丢失本地修改。
- #5 将本地同步回来的改动, push 到 gitbub 上。
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
$ git fetch upstream
remote: Counting objects: 9705, done.
remote: Compressing objects: 100% (4870/4870), done.
remote: Total 9705 (delReceiving objects: 99% (9t678/9705)a 277, 7.93 3), reusereused 0
Receiving objects: 100% (9705/9705), 7.93 MiB | 5.00 KiB/s, done.
Resolving deltas: 100% (2773/2773), completed with 9 local objects.
From https://github.com/MrGPanPan/coding2017
* [new branch] master -> upstream/master
$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
$ git merge upstream/master
Performing inexact rename detection: 100% (93534/93534), done.
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config
To squelch this message and adopt the new behavior now, use:
git config
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 9704, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4825/4825), done.
Writing objects: 100% (9704/9704), 7.92 MiB | 0 bytes/s, done.
Total 9704 (delta 2776), reused 9698 (delta 2773)
remote: Resolving deltas: 100% (2776/2776), completed with 10 local objects.
To https://github.com/XeCtvi/coding2017.git
29537ed..dafc139 master -> master