2021年4月9日星期五

How to rebase effectively without letting commits pile up locally?

I'm trying to implement a workflow whereby I rebase my feature branch off master before merging it in. I've found that it's not a good idea to push my local commits on the feature branch to the remote repo before rebasing, as that essentially duplicates the commits on the feature branch and requires a subsequent force push as described here. (Git 101 I know.) I definitely don't want to get into the habit of --force pushing commits, and by letting commits first accumulate locally without pushing, then rebasing, and then pushing I avoid this.

However, I'd like to have my commits pushed to the remote server somewhere before rebasing, particularly in cases when the local repo is on a local machine (which could experience HD failure, etc.). Is there a way to do this, without --force pushing? I've thought of creating some kind of intermediate my_work branch but it seems like this would also lead to the 'local/remote diverged' problem. Maybe there's a clever (or not so clever) way of doing this I just haven't thought of though.

https://stackoverflow.com/questions/67030443/how-to-rebase-effectively-without-letting-commits-pile-up-locally April 10, 2021 at 11:08AM

没有评论:

发表评论