I will try to describe the sequence of git operations that leads to the misunderstood behaviour.
Starting from this scenario with a local (LM) and remote (RM) branch master with commits m1 and m2:
RM --- m1 --- m2
LM --- m1 --- m2
A local feature branch is created (LF) and a commit f1 is made
RM --- m1 --- m2
LM --- m1 --- m2
LF --- m1 --- m2 --- f1
This branch is pushed to track a remote branch (RF) which is then merged into remote master (RM):
RM --- m1 --- m2 --- f1
LM --- m1 --- m2
RF --- m1 --- m2 --- f1
LF --- m1 --- m2 --- f1
The remote feature branch (RF) is deleted and a new commit x is added to remote master (RM) as a result of a merge:
RM --- m1 --- m2 --- f1 --- x
LM --- m1 --- m2
LF --- m1 --- m2 --- f1
Local master branch (LM) is updated and a new commit is made to local feature branch (LF):
RM --- m1 --- m2 --- f1 --- x
LM --- m1 --- m2 --- f1 --- x
LF --- m1 --- m2 --- f1 --- f2
When the local feature branch (LF) is pushed, commits f1 and f2 are seen as commits to be pushed but only f2 was added since last push. What is the explanation for this behaviour? What is happening behind the scenes in git?
Note that if at this point a new branch is created from master and f2 is cherry-picked from LF, when the push operation is performed only f2 appears as a commit to be pushed.