Force pushing to different Git remotes

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 nee…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Force pushing to different Git remotes." Mark Otto | Sciencx - Tuesday July 27, 2021, https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/
HARVARD
Mark Otto | Sciencx Tuesday July 27, 2021 » Force pushing to different Git remotes., viewed ,<https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/>
VANCOUVER
Mark Otto | Sciencx - » Force pushing to different Git remotes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/
CHICAGO
" » Force pushing to different Git remotes." Mark Otto | Sciencx - Accessed . https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/
IEEE
" » Force pushing to different Git remotes." Mark Otto | Sciencx [Online]. Available: https://www.scien.cx/2021/07/27/force-pushing-to-different-git-remotes/. [Accessed: ]
rf:citation
» Force pushing to different Git remotes | Mark Otto | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.