DEV Community

loading...

Discussion on: Remove accidentally pushed file from a git repository history in 4 simple steps

Collapse
leohajder profile image
Leo Hajder

Cool :)

If you use git rebase -i on a branch, you should specify where you want to push. The default origin is origin/master, so be careful and don't overwrite your main branch.

So, let's say you're on a branch called feature/new-stuff and you want to rewrite its history...
Do the steps above, just remember to push to the right origin in the end. In this case:
git push -f origin feature/new-stuff

Collapse
moshe profile image
Moshe Zada Author

Hi @leo ,
Looking at git-scm.com/docs/git-config it seems like the default push.default is simple.
simple - in centralized workflow, work like upstream with an added safety to refuse to push if the upstream branch’s name is different from the local one.
upstream - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called @{upstream}). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).

So if the branch names differ the push will be refused.

Collapse
leohajder profile image
Leo Hajder

Oh... Ok, this is new to me. Thanks for the clarification.