简体   繁体   中英

Is it a problem to squash some commits on a PR and then rebase onto master

I had about 10 commits on a PR in GitHub and squashed them (via an interactive rebase) and forced push it.

I now need some changes from master and was wondering if there's any reason why running on my feature branch

git rebase master

would cause problems? Is there another way that I should handle this.

(I assume your PR is targeting master)

That depends,

If you squash only new commits, then there is no problem.

On the other hand, if you (also) squash commits that are on master, then prepare for some conflicts.

Good to know, if you rebase a squashed commit - compared to rebasing the multiple commits - there is a lower change of conflicts. Of course that only counts for if you made the squash only of the new commits.

PS: personally I would recommend to use git rebase origin/master - then you can't forget to update your local master (and saves some switches between branches).

Or even better in my opinion, enable "pulled rebases" ( git config --global pull.rebase true ) and just use git pull master (saves a fetch command to execute)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM