The answer you're initially asking is how to move the commits. The literal answer is that you can't move commits, but you can rebase them (create new commits that apply the same changes over a different commit, and move the branch to the new commits) which you already know how to do. So that's not really your question.
The reason you can't push is that doing so would remove history from the branch. After the rebase you have
A' -- B' -- C' <--(feature)
/
x -- x -- x -- x -- x <--(develop)
\
A -- B -- C <--(origin/feature)
Normally when you push an update to a branch, the corresponding remote branch is "reachable" from your branch In this case it's not so because you moved the branch (in a manner other than "added new commits to the tip of the branch").
By default git rejects this push because if anyone else has fetched feature
, moving it in this way will cause them problems. You can coordinate with the other users to work through those problems, and so you can override git's default decision to reject the push. Beware that if you do this without having coordinated with the other devs, it will cause problems for everyone (including your work potentially ending up being undone).
For information about how to coordinate the clean-up, see the git rebase
documentation under "recovering from upstream rebase". You can find it here: https://git-scm.com/docs/git-rebase
If you have all that handled (or, in the simple case, if nobody else has a copy of that branch), then you can "force" the push
git push -f
The one caveat is, depending on how git is hosted, the server may or may not be configured to allow you to do force-pushes to that branch. If not, then that's a team-level rule saying "you can't rebase branches you've already pushed". In that case, you'd have to decide if it's worth it to you to just merge develop
into feature