问题描述
根据还建议来抵制这一事实的命令将不再使用与本地分支关联的跟踪信息。
函数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)'
发布了,但现在引用 ,来自。
According to the Github for Mac blog announcement,
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.
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:
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如何同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!