Github for Mac如何同步? [英] How does Github for Mac synchronize?

查看:134
本文介绍了Github for Mac如何同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据还建议遵循别名来抵制这一事实的命令将不再使用与本地分支关联的跟踪信息。

 函数git_current_branch(){
git symbolic -ref HEAD 2> / dev / null | sed -e's / refs \ / heads\ ///'
}

别名gpthis ='git push origin HEAD:$(git_current_branch)'
别名grb ='git rebase -p'
alias gup ='git fetch origin&& grb origin / $(git_current_branch)'

Jason Weathered 发布了 http:// jasoncodes.com/posts/gup-git-rebase ,但现在引用 git-up ,来自 Aanand Prasad


According to the Github for Mac blog announcement,

Once you're ready to share your commits, or pull in remote commits — just press the Sync Branch button. We'll perform a smarter version of pull --rebase && push that reduces merge commits but doesn't rewrite your merges.

What is "a smarter version" of pull --rebase && push? What exactly are they doing? Is it possible to do this "smarter" thing on the command line?

解决方案

The blog post "Rebasing Merge Commits in Git" (from Glen Maddern) illustrates the danger of a git pull --rebase when you have made local merges:

If you do a git pull --rebase of master on top of origin/master now, you would delete your local merge.
See the next picture after the rebase: no more merge commit.

This is bad for a whole lot of reasons.

  • For one, the feature commits are actually duplicated, when really I only wanted to rebase the merge. If you later merge the feature branch in again, both commits will be in the history of master.
  • And origin/feature, which supposed to be finished and in master, is left dangling.
    Unlike the awesome history that you get from following a good branching/merging model, you’ve actually got misleading history.
    For example, if someone looks at the branches on origin, it’ll appear that origin/feature hasn’t been merged into master, even though it has! Which can cause all kinds of problems if that person then does a deploy. It’s just bad news all round.

That is what Github for (Mac|Windows) would detect and avoid.

If you didn't detect it in time, the same blog post mentions the following recover:

[master] git reset --hard origin/master
HEAD is now at 9f3e34d sneaky extra commit
[master] git merge --no-ff feature

Actual Solution:

You can achieve the desired result:

Instead of using git pull --rebase, use a git fetch origin and git rebase -p origin/master

I suppose the "smarter version" of pull --rebase is that combination of "fetch + rebase preserving the merge".

Glen also proposes the following aliases to counter the fact that this sequence of command would no longer use the tracking information associated to a local branch.

function git_current_branch() {
  git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'
}

alias gpthis='git push origin HEAD:$(git_current_branch)'
alias grb='git rebase -p'
alias gup='git fetch origin && grb origin/$(git_current_branch)'

Jason Weathered posted a "http://jasoncodes.com/posts/gup-git-rebase", but now refers to git-up, from Aanand Prasad.

这篇关于Github for Mac如何同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆