I opened pull request and I had several commits on it. Can I will combine several commits on one on opened pull request before my teem lead will merged on master branch.
Asked
Active
Viewed 17 times
-2
-
What's your remote? Most have a *squash* option when merging PRs. – jonrsharpe Dec 19 '20 at 20:21
-
github. Without squash i can do it ? – ts-alan Dec 19 '20 at 20:24
-
Why do you want to not use the thing that's for the thing you want to do? – jonrsharpe Dec 19 '20 at 20:25
-
do you mean squash? – ts-alan Dec 19 '20 at 20:26
-
1Yes. It does what you want, combining several commits to one: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges#squash-and-merge-your-pull-request-commits. – jonrsharpe Dec 19 '20 at 20:28
-
i can do it before merging on master ? because squash - it is when i will mege on master – ts-alan Dec 19 '20 at 20:31
-
Why? What *problem* are you trying to solve? If you want to update the PR, just update the branch you made it from. – jonrsharpe Dec 19 '20 at 20:31
-
because i cannot rule for merge on master. But my team lead asked me do all pull request via one commit – ts-alan Dec 19 '20 at 20:34
-
Then why don't you ask your team lead why they don't just squash it on the merge? Or, if they don't know how to do that, how you can do what they're asking you to – jonrsharpe Dec 19 '20 at 20:35
1 Answers
0
While on your PR branch locally:
Squash the last n commits (replacing n with a number)
git reset --soft HEAD~n git commit
Push this back to your branch, which will require force since history is rewritten.
git push --force-with-lease

grg
- 5,023
- 3
- 34
- 50