If I work on my personal feature branch that I periodically rebase on master and force-push into origin, and I accidentally do git up after rebasing but before force-pushing, the result is weird and confusing: git up rebases local feature on remote feature, which produces rebased copies of all new commits in master.

Maybe it could be possible to try and detect such situation and at least warn that something weird is going on? For example, check if there are local/remote branches that we will be leaving behind after rebase?
Or, I don't know, if that would bring a lot of complications and slow down operation for everyone, while addressing a relatively unusual workflow, oh well, at least if someone else stumbles upon it, they'll see this issue here.
This shell script reproduces the problem:
#!/bin/sh
set -euxo pipefail
rm -rf remote/ local/
git init remote
echo a >> remote/a.txt # this file will be modified on remote
echo b >> remote/b.txt # this file will be modified on local
git -C remote add a.txt b.txt
git -C remote commit -am "0"
echo a >> remote/a.txt
git -C remote commit -am "1"
git clone remote local
git -C local checkout -b feature
echo b >> local/b.txt
git -C local commit -am "feature"
git -C local push --set-upstream origin feature
echo a >> remote/a.txt
git -C remote commit -am "2"
echo a >> remote/a.txt
git -C remote commit -am "3"
echo a >> remote/a.txt
git -C remote commit -am "4"
git -C local up # OK, updates master
git -C local rebase master
git -C local up # rebases local/feature on remote/feature, producing rebased versions of commits 2-3-4
If I work on my personal feature branch that I periodically rebase on master and force-push into origin, and I accidentally do
git upafter rebasing but before force-pushing, the result is weird and confusing: git up rebases local feature on remote feature, which produces rebased copies of all new commits in master.Maybe it could be possible to try and detect such situation and at least warn that something weird is going on? For example, check if there are local/remote branches that we will be leaving behind after rebase?
Or, I don't know, if that would bring a lot of complications and slow down operation for everyone, while addressing a relatively unusual workflow, oh well, at least if someone else stumbles upon it, they'll see this issue here.
This shell script reproduces the problem: