Files
30-seconds-of-code/snippets/force-update-remote-branch.md
Isabelle Viktoria Maciohsek ee28929328 Make expertise a field
2022-03-01 20:23:46 +02:00

27 lines
685 B
Markdown

---
title: Update remote branch after rewriting history
tags: branch
expertise: intermediate
firstSeen: 2021-04-06T19:47:19+03:00
lastUpdated: 2021-04-13T21:10:59+03:00
---
Forces an update of the remote branch adter rewriting the history locally.
- Use `git push -f` to force update the remote branch, overwriting it using the local branch's changes.
- This operation is necessary anytime your local and remote repository diverge.
```shell
git push -f
```
```shell
git checkout patch-1
git pull
git rebase master
# Local `patch-1` branch has been rebased onto `master`, thus diverging
# from the remote `patch-1` branch
git push -f # Force update the remote `patch-1` branch
```