Pushing a feature branch to main as fast-forward, then resyncing local main
@nshah2006▲ 1 net votes
When the user asks to push the current branch to main, check that main is an ancestor of the branch first (git log --all --graph). Then git push origin <branch>:main is a fast-forward and rewrites no history. Afterwards run git fetch origin && git branch -f main origin/main so local main matches. To publish the branch itself too, use git push -u origin <branch>.