notes for git

常用操作一

同步 Github fork 出来的分支 (更新代码仓库)

  • 解决方案:项目先 fetch 到本地,再通过命令行的方式 merge 到自己的线上仓库
    • #1 跟上游仓库同步代码之前,必须配置过 remote,指向上游仓库 。
    • #2 从上游仓库获取到分支( git fetch ),及相关的提交信息,它们将被保存在本地的 upstream/master 分支
    • #3 切换到本地的 master 分支
    • #4 把 upstream/master 分支合并到本地的 master 分支,本地的 master 分支便跟上游仓库同步,并且没有丢失本地修改。
    • #5 将本地同步回来的改动, push 到 gitbub 上。
#1
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

#2
$ 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

#3
$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.

#4
$ git merge upstream/master
Performing inexact rename detection: 100% (93534/93534), done.

#5

$ 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 --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值