Is it okay to rebase after pushing if you've forked a repo and you're the only user of the fork?

Viewed 87

I've read other SO answers about how dangerous it is to rebase after pushing and how people who don't know what they're doing (i.e., me) shouldn't use --force.

I have a forked repo and I'm the only user of the fork. I want to make a PR of the repo I forked from. I have already pushed to my fork, but I'd like to clean up my commit history, either by rebase or some other method, before I do. Is this going to cause some kind of problem I don't understand?

1 Answers

I have already pushed to my fork, but I'd like to clean up my commit history, either by rebase or some other method, before I do? Is this going to cause some kind of problem I don't understand?

Go right ahead. If you're not sharing your work with anybody else, rebase and force push as much as you want. Honestly, if you're going to contribute a PR to a project, people generally appreciate if it you take the time to clean up your commit history so that each commit in your PR is meaningful.

The only thing to keep is mind that you should only rebase your changes; don't change commits that are part of the upstream repository (because if you do that there's no sane way to generate a PR from your branch, because your repository no longer shares a common history).

Lastly, a word of advice: even when working with my own private fork of an upstream repository, I always make changes on a branch that I create to contain whatever changes I'm proposing, rather than working on the master branch. This avoids confusion between my master branch, the upstream master branch, etc, and means I can set up my local directory so that master always refers to the upstream repository.

Related