Don't checkout branch after rebase in git

to don something
don synonym
don urban dictionary
don medical abbreviation
don meaning slang
don meaning italian
don movie
don and doff

I'm on my branch (not master) and I need to get the latest version of master locally. I do next still staying on my branch:

git fetch
git rebase origin/master master

After this master is checked out and I need to go back to my branch. Is there any way to avoid the check out local master during rebase?

The short answer is unfortunately no.

From the doc :

If is specified, git rebase will perform an automatic git switch before doing anything else. Otherwise it remains on the current branch.

This is the same for merges : you only work on a checked out branch for these operations, since they theretically could result in a conflicting state and would then need to be resolved on the spot.

A sort of workaround would be to chain (with && to stop if the rebase returns an error) the subsequent checkout back in an alias.

# fm for "fresh master"
git config --global '!git fetch && git rebase origin/master master && git checkout -'

Don, synonyms: university teacher, (university) lecturer, fellow, professor, reader, lector, college tutor, academic, scholar, egghead, senior common room 1. Don (also dōn) Used as a courtesy title before the name of a man in a Spanish-speaking area. 2.

The accepted answer works most of the time, But if origin/master and master are up to date, the rebase does nothing and using git checkout - will put you back in whatever previous branch.

The solution is to check the diff between the two reference before "rebasing".

Also I think we can make it more generic by using an function alias, i.e:

refresh = "!f() { \
  git fetch \
  && git diff origin/$1 $1 \
  || { \
        git rebase origin/$1 $1 \
        && git checkout - \
     ;} \
;}; f"

It is easier to define it directly in the config file because the git config command will try to escape quote and mess thing up.

This way you can do git refresh master or any other branch. If necessary you can rename the alias with a shorter name or use a double alias to have both, ie:

 git config --global alias.rf refresh

Good idea for a alias I'll certainly will be using it. Thanks @vitalii

Don, Don definition is - to put on (an article of clothing). How to use don in a sentence. a song or ode in praise or honor of God, a deity, a nation, etc. a style of popular music for dancing, usually recorded and with complex electronic instrumentation, in which simple, repetitive lyrics are subordinated to a heavy, pulsating, rhythmic beat.

If you want the changes to be rebased to your branch, you don't need to checkout master. You can stay on your branch and do -

git fetch

and then

git rebase origin/master

This will rebase the commits from your local branch on top of the ones from origin/master. It won't update your local master.

Don (2006 film), A don is a guy that everyone wants to be like. He is not only sexy and muscular but amazing in bed aswell. He can rock anyone. Being a don is a talent that not  Dôn, in Celtic mythology, leader of one of two warring families of gods; according to one interpretation, the Children of Dôn were the powers of light, constantly in conflict with the Children of Llyr, the powers of darkness. In another view, the conflict was a struggle between indigenous gods and those of an invading people.

Don (Film franchise), verb (used with object), donned, don·ning. to put on or dress in: to don one's clothes. Origin of  Vijay is recruited by a police officer to masquerade as his lookalike Don, the leader of an international gang of smugglers. Things go wrong when the officer is killed and Vijay is left to fend for himself.

Don, VerbEdit. don (third-person singular simple present dons, present participle donning, simple past and past participle donned). (  Edward Don and Company is the world's leading distributor of foodservice equipment and supplies. Online ordering

don, To don means to put on, as in clothing or hats. A hunter will don his camouflage clothes when he goes hunting. A don is a guy that everyone wants to be like. He is not only sexy and muscular but amazing in bed aswell. He can rock anyone. Being a don is a talent that not everyone can achieve.