git Force Push

Rebasing is a frequent task for anyone using git. We sometimes use rebasing to branch our code from the last changes or even just to drop commits from a branch. Oftentimes when trying to push after a rebase, you’ll see something like the following: hint: Updates were rejected because the tip of your current branch […]

The post git Force Push appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

Rebasing is a frequent task for anyone using git. We sometimes use rebasing to branch our code from the last changes or even just to drop commits from a branch.

Oftentimes when trying to push after a rebase, you’ll see something like the following:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Commonly developers will use the --force or -f flags during a push to force pushing code changes:

git push origin my-branch --force
# or
git push origin my-branch -f

I was recently surprised to find out that you could also prefix the branch name with + to force a push:

git push origin +my-branch

The + syntax is interesting but doesn’t seem intuitive so it’s not a practice I’d use, but that doesn’t mean you shouldn’t!

The post git Force Push appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2022-08-19T16:35:41+00:00) git Force Push. Retrieved from https://www.scien.cx/2022/08/19/git-force-push/

MLA
" » git Force Push." David Walsh | Sciencx - Friday August 19, 2022, https://www.scien.cx/2022/08/19/git-force-push/
HARVARD
David Walsh | Sciencx Friday August 19, 2022 » git Force Push., viewed ,<https://www.scien.cx/2022/08/19/git-force-push/>
VANCOUVER
David Walsh | Sciencx - » git Force Push. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/08/19/git-force-push/
CHICAGO
" » git Force Push." David Walsh | Sciencx - Accessed . https://www.scien.cx/2022/08/19/git-force-push/
IEEE
" » git Force Push." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2022/08/19/git-force-push/. [Accessed: ]
rf:citation
» git Force Push | David Walsh | Sciencx | https://www.scien.cx/2022/08/19/git-force-push/ |

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.