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.

  • Wget other user's private repository on Github
  • Is a commit a branch in itself ? - git
  • How to make git aware of move/deleted/new files automatically
  • how to create a null branch in jgit
  • Is it posssilbe to do a selective “git checkout --ours” on only take “ours” in the conflicted regions of the conflict file
  • Getting TravisCI to commit and push a modified file with Tags (releases)
  • 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?

  • git bundle warning ref is excluded by the rev-list options
  • Given a specific revision, how do I compare or diff a file with my working copy or head revision?
  • Ignore a file in git but have it downloaded when the project is cloned
  • How to run meteor on startup on Ubuntu server
  • Git merge master into branch commit ordering
  • Git post-receive Host Key verification failed
  • 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.