This content originally appeared on @mdo and was authored by Mark Otto
My Git/GitHub workflow has continued to evolve and now makes extensive use of rebasing and squashing instead of merge commits. While this is easy for branches in projects I maintain, it’s more complicated for forks of my projects. In those cases, I need to checkout, rebase, squash, and force push a branch to a different remote with a different branch name.
Once you get your own copy of the fork’s branch locally and you’re ready to force push your rebased and/or squashed changes, here’s how you can push your changes from the terminal:
git push remoteName localBranch:remoteBranch --force
Before you push, you may need to add the fork as a new Git remote:
git remote add remoteName git:https://github.com/user/repo.git
Not familiar with force pushing, or squashing and rebasing? Consider exploring the GitHub rebase docs.
This content originally appeared on @mdo and was authored by Mark Otto

Mark Otto | Sciencx (2021-07-27T00:00:00+00:00) Force pushing to different Git remotes. Retrieved from https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.