Can I say that other people_git commit in the submitted PR?

I got PR and want to crush commits, so nice.

I'm not sure if I can do this, or should the relevant authors do this? Of course, I want to keep the name of the author referring to their squash.

NOTE: this question is not about me, crushing my own commits .

Here's what PR looks like in Git:

enter image description here

or via cli:

c:\Projects\Foo>git log --pretty=oneline 7fab9ae1031c13414909668f342582bdc8081f5a <Author - Red> a02270b2014fd3995456773cd7badc7df0c72cf6 <Author - Blue> 6ae3d6c8b5a8b037c0e4dc88d24ec5598ff1933e <Author - Blue> 100f6513aacbe431b56f3082597749cddca284c8 <Author - Blue> d263a5c8924053678f455b5ee8515bbb16aacf49 <Author - Blue> c3cc5dbc13ac77e0a552a2d3132d255df3c7a6e4 <Author - Blue> 71f89b3f3dd583cd97d4a0806a973a4d1af64fe9 <Author - Red> f14ef616a852f3a7311f4f7b9e05d460e0574422 <Author - Red> 015f30b3828828404b5549ee8a7df2aefdfa9424 <Author - Red> 9b22a4d2ded54cb754883d9d6418a39eb34df7cf <Author - Red> 33a10e9828d04cf82439a6c60b8cf4c0c2f122a3 <Author - Red> 4615c7747c4546809b29e063986c697c7c64cbc4 Added Specific naming rules, section. b8ee154e38338022649caef40945c6f0297a59ce Added method parameters, section. bc860c7609cc80caf41fc5944c1b39201019a80e Added Input and View Models, section. ad6b3e4bee1cb9d8afcf9cd1fa8815769d80133b Fixed bad markdown formatting. 5929d5b38aad8bb7cc3da4976dd81883eab0f999 Added more testing info. 18b64dfc3769766ac2bb841e6346b555d00751f1 Create README.md d7761e57a5bbd7de587b766c83d2a3134c0bc58b Added xUnit and Shouldly NuGet packages. 7f2ea8cdd97958d347df8079ef2eebb6b7f1647c We need unit tests.... ee31bbfe0572e0e49872edcf1a6fc2c426ed0d15 :money_with_wings: We are alive! 

commits that have posts are mine, not part of this PR.

Is there anything I can do? Or do I need a different author?

+5
source share
1 answer

The comments ended up turning into an answer, so I will summarize them here:

I'm not sure if I can do this, or should the relevant authors do this? Of course, I want to keep the name of the author referring to their squash.

If you crush any commits, you will only get one commit, and commit can only have one author. They may still be referenced in the commit message (by default, Git), but you will lose personality for the literal author of the commit.

So I can not crush blue commits (into one) and then red commits (into one)? so there are two in PR?

Yes, you can do this, and there should be a crush that you offer in pull requests so that you carry only one commit for each of them. If you go through all the blue commits into one and all the red commits, you will achieve what I think you need to clear the git log while keeping the author’s history.

Excellent! .. any suggestions how to do this?

Sure. You can interactively repack to crush multiple commits together. Your problems will come when you have a red commit on either side of the blue commits, which limits your squash ability.

For blue commits, you can squash them into the first commit on the list when you execute git rebase -i HEAD~11 (which loads over the last 11 commits for an interactive reboot).

I mocked some dummy commits for use as an example:

 $ git log --oneline 7e8be9c Red b740f97 Blue 325b375 Blue 553d733 Red bb5599b Red 

In your console, select “p” or “pick” for the first blue commit in the list (bd63d63) and for everyone else, give it “f” or “fixup” to cancel your commit messages or “s” or “squash”, if you want to keep commit messages for them:

 $ git rebase -i HEAD~5 pick bb5599b Red pick 553d733 Red pick 325b375 Blue fixup b740f97 Blue pick 7e8be9c Red 

When the reboot finishes, your blue commits will be crushed together:

 $ git log --oneline a341d97 Red 488c19e Blue 553d733 Red bb5599b Red 

Here it can get complicated depending on whether Red and Blue have touched the same files or not.

If you don’t have one, it’s best to cherry-pick blue commit into a separate branch (without red or blue) or reconfigure it, reload the original and crush the red commits, and discard the Blue commit, then reinsert the temporary branch, for example:

 $ git checkout -b tempbranch $ git reset --hard XXXXXXX # this is the commit BEFORE any red or blues $ git cherry-pick 488c19e 

Git Now the log will tell you that you have one compressed blue message.

Go back to your main branch and reinstall again, this time skipping the blue commit and crushing the red ones together:

 $ git rebase -i HEAD~4 pick bb5599b Red fixup 553d733 Red drop 488c19e Blue fixup a341d97 Red 

Git Now the magazine will show you that you have only one red commit. Now you are cherry-pick Blue again:

 $ git cherry-pick 488c19e $ git log --oneline fc96b04 Blue 0280ef9 Red 

You will encounter problems if they all relate to the same files. In this case, you just need to keep highlighting red around blue.

Attention!

I highly recommend that you advise all members of your Github project to distribute all their commits to one of them as part of the traction request process, then you will not have to solve these problems yourself.

NTN.

+3
source

Source: https://habr.com/ru/post/1235656/


All Articles