Array
University of Oregon

Git “Force Push”

Use this command only on private repo on Github that is exclusively yours. You should never do this on a shared repo.

Git Error

If you try to push changes to your branch on your Github repo and get an error like this:

Branch master ahead of origin/master by 1 commit

Solution

You can override the remote repo on Github by using a force push command (note that -f is short for –force):

git push -f <remote> <branch>

Example

git add -A .
git commit -m "message"
git push -f origin p1-branch
Skip to toolbar