How to fast-forward a branch to head?

I switch to master after develop on a branch for a long time. The log shows:

Your branch is behind ‘origin/master’ by 167 commits, and can be fast-forwarded.

  • Why is EGit showing unstaged changes in a freshly cloned repository?
  • git push gets “Everything up-to-date” after committed
  • why config folder is not pushed?
  • Revert a merged pull request on BitBucket
  • How do I exclude directories when using git log?
  • Git Branching - Trusted on large projects?
  • I tried:

    git checkout HEAD

    It has no effect. This is cause because that I have checkout out an intermediate commit on master.

    How to make master stay on head?

  • TortoiseGit modified sign (icon overlay) is not updating
  • What is the difference between staging and caching?
  • Enforce core.autocrlf=input through .gitattributes
  • Git: remove folder from history except for one author
  • Backing up a DB with Git - a good idea?
  • removing file from git history doesn't work
  • 7 Solutions collect form web for “How to fast-forward a branch to head?”


    git checkout master
    git pull origin

    will fetch and merge the origin/master branch (you may just say git pull as origin is the default).

    Try git merge origin/master. If you want to be sure that it only does a fast-forward, you can say git merge --ff-only origin/master.

    In your situation, git rebase would also do the trick. Since you have no changes that master doesn’t have, git will just fast-forward. If you are working with a rebase workflow, that might be more advisable, as you wouldn’t end up with a merge commit if you mess up.

    username@workstation:~/work$ git status
    # On branch master
    # Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
    #   (use "git pull" to update your local branch)
    nothing to commit, working directory clean
    username@workstation:~/work$ git rebase
    First, rewinding head to replay your work on top of it...
    Fast-forwarded master to refs/remotes/origin/master.
    # On branch master
    nothing to commit, working directory clean
    git checkout master
    git pull

    should do the job.

    You will get the “Your branch is behind” message every time when you work on a branch different than master, someone does changes to master and you git pull.

    (branch) $ //hack hack hack, while someone push the changes to origin/master
    (branch) $ git pull   

    now the origin/master reference is pulled, but your master is not merged with it

    (branch) $ git checkout master
    (master) $ 

    now master is behind origin/master and can be fast forwarded

    this will pull and merge (so merge also newer commits to origin/master)
    (master) $ git pull 
    this will just merge what you have already pulled
    (master) $ git merge origin/master

    now your master and origin/master are in sync

    If you are standing on a different branch and want to checkout the newest version of master you can also do

    git checkout -B master origin/master

    No complexities required
    just stand at your branch and do a git pull it worked for me

    Or, as a second try git pull origin master only in case if you are unlucky with the first command

    Move your brunch pointer to the HEAD:

    git branch -f master

    Your branch master already exists, so git will not allow you to overwrite it, unless you use… -f (this argument stands for --force)

    Or you can use rebase:

    git rebase HEAD master

    Do it on your own risk 😉

    Git Baby is a git and github fan, let's start git clone.