git fast-forward one commit
You can git reset
to it, but for general safety and cleanness, I prefer to use git merge --ff-only
. To use it, check out the branch you want fast-forwarded (you have already), then run git merge --ff-only <commit-hash>
:
git merge --ff-only 9aeb07e
I use this command so often that I made an alias for it, git mff
(merge fast forward).
Edit, Nov 2020: note that you do not have to use a raw hash ID here; git mff origin/somebranch
works fine too. You can use a raw hash here. This is part of a general rule in Git: if you can use a raw hash, you can use a branch name, a tag name, a remote-tracking name, and so on.
There are a few special cases around this general rule, and in particular, if you use a raw hash ID with the git checkout
command, you will get what Git calls a detached HEAD, while if you use a branch name with git checkout
, you will be "on the branch" (i.e., an attached HEAD: the opposite of detached, although Git documentation never calls it this: it just says "on a branch"). The new git switch
command, in Git 2.23 and later, is better about this in that if it's going to switch to detached-HEAD mode, it demands that you add the --detach
option. With this git mff
alias, however, there's no special case to worry about.
git checkout feature/QOL-1649-install-chrome
git merge --ff-only 9aeb07e
or
git reset --hard 9aeb07e
instead of merge.