How to fast-forward a branch to head

Question

I switched to master after developing on a branch for a long time. The log shows:

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

I tried:

git checkout HEAD

It doesn't have any effect. This is because I have checked out an intermediate commit on master.

How can I make master stay on head?

Answer

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.

How to create a new branch from a tag?

gitignore all files of extension in directory