There is a remote repository

x1->x2->x3 \master 

I made it fork and locally new branch

  /master x1->x2->x3 \y1->y2->y3 \local-develop 

How can I make a push-request with the last commit so that the entire history of commits is not visible?

  /master x1->x2->x3->y3 \y1->y2->y3 \local-develop 

The goal is to add the result of the work to the remote repository in a separate branch, while not cluttering up the remote repository with extra comets with a history of development.

I tried to do so

 git checkout local-develop git rebase -i master *squash all commit* 

But it turns out that they stray into one in the local-develop branch.

Thank you in advance.

  • Schemes are excellent)) - Nick Volynkin

1 answer 1

This is not how it works.

The problem is that commit, semantically , is a set of changes , not a state.

Therefore, to send the last state, you need to send the change set from the initial ( x3 , not inclusive) to the final ( y3 ).

And since you want to present this set with one commit, you will have to make one commit that contains the changes in y1 .. y3 . With rebase -i you did it.

If you don’t want to lose the original commits, you can make squash in a separate branch (just before starting the rebuy, make git checkout -b local-develop-squashed while in the local-develop branch).

After rebuy get this state:

 x1->x2->x3-\ {master} | |->y1->y2->y3 {local-develop} | \->z1 {local-develop-squashed} 

In the local-develop-squashed compared to master , one beautiful commit is issued.
From this thread and need to do a pull request.

This, of course, has problems. If you want to complete this pull request, you will have to push --force each time, which is generally very dangerous . Therefore, you can download the original history from the heap of commits, and only when they give you a go, make a heap of commits into one right on the spot and do push --force .

And some of them use the --no-ff option when using the PR --no-ff , and the history is viewed with the help of git log --first-parent master , as a result of which the detailed history of the feature branches is not shown, and the PR looks like separate commits. And for this you do not need any shamanism with rewriting commits and push "by force".

  • Thanks for the answer. Finish pull request i.e. change it? Why need --force? - Dmitry Donkey
  • @DmitryDonkey because if you want to have only one commit at any given time in PR, you will have to overwrite the commit that is already there. - D-side
  • EMNIP, you can do a merge squash - Pavel Mayorov
  • @PavelMayorov yes, or so, then it makes no sense to bother with manual gluing at all. - D-side
  • @ D-side I assumed that commits in a remote branch would "stack" from push to push - z1-> z2-> z3 -> ... I just won't see the "implementation" - intermediate commits. - Dmitry Donkey