<div dir="ltr">Ah, 'git graph' I will try that next time.<div><br></div><div>I use 'git rebase -i HEAD~N', but you need an N. </div><div><br></div><div>After you 'git rebase origin/main' you get other commits interspersed in with yours, so I try to rebase -i before rebasing over main. Then rebase over main and you have a clean and updated branch. </div><div><br></div><div>Pick N to be large enough to cover the commits that you want to clean up. Don't touch the ones that are not yours from main, the last time you rebased over main.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021 at 10:02 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com">junchao.zhang@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am a naive git user, so I use interactive git rebase.  Suppose I am on the branch I want to modify, <div><br></div><div>1) Use git graph to locate an upstream commit to be used as the base</div><div><span style="font-family:monospace">$ git graph</span><br></div><div><font face="monospace">* 0d5433e9 (HEAD -> jczhang/sf-change-api) SF: rename SFCreateEmbeddedSF to SFCreateEmbeddedRootSF<br>* e7314fbb SF: add an MPI_Op argument to SFBcast<br>* 83df288d Replace MPIU_REPLACE with MPI_REPLACE<br>*   b434c516 Merge branch 'barry/2021-02-02/petscsf-communication-specific' into 'main'<br>|\<br>| * 62152ded (barry/2021-02-02/petscsf-communication-specific) PetscSFView() never called viewer for the specific type (bug), hence many output files were incorrect.<br>* |   a4f5d9b4 Merge branch 'jose/upgrade-magma' into 'main'<br></font></div><div><br></div><div>2) Suppose we choose b434c516 as the base. All commits we want to squash are after it.  Do interactive git rebase. It shows a screen for you to edit.  Read the help, which is helpful for new users</div><div><span style="font-family:monospace">  $ git rebase -i b434c516</span><br></div><div><font face="monospace">pick 83df288d Replace MPIU_REPLACE with MPI_REPLACE<br>pick e7314fbb SF: add an MPI_Op argument to SFBcast<br>pick 0d5433e9 SF: rename SFCreateEmbeddedSF to SFCreateEmbeddedRootSF<br><br># Rebase b434c516..0d5433e9 onto b434c516 (3 commands)<br>#<br># Commands:<br># p, pick <commit> = use commit<br># r, reword <commit> = use commit, but edit the commit message<br># e, edit <commit> = use commit, but stop for amending<br># s, squash <commit> = use commit, but meld into previous commit<br># f, fixup <commit> = like "squash", but discard this commit's log message<br># x, exec <command> = run command (the rest of the line) using shell<br># b, break = stop here (continue rebase later with 'git rebase --continue')<br># d, drop <commit> = remove commit<br># l, label <label> = label current HEAD with a name<br># t, reset <label> = reset HEAD to a label<br># m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]<br># .       create a merge commit using the original merge commit's<br># .       message (or the oneline, if no original merge commit was<br># .       specified). Use -c <commit> to reword the commit message.<br>#<br># These lines can be re-ordered; they are executed from top to bottom.<br>#<br># If you remove a line here THAT COMMIT WILL BE LOST.<br>#<br># However, if you remove everything, the rebase will be aborted.<br>#<br># Note that empty commits are commented out</font><br></div><div><br></div><div>3) Suppose we want to squash the last two commits to 83df288d, replace their pick with s (or f, see the help for difference), save and exit the screen</div><div>pick 83df288d Replace MPIU_REPLACE with MPI_REPLACE<br><font color="#ff0000">s </font>e7314fbb SF: add an MPI_Op argument to SFBcast<br><font color="#ff0000">s</font> 0d5433e9 SF: rename SFCreateEmbeddedSF to SFCreateEmbeddedRootSF<br></div><div><br></div><div>A new screen shows up</div><div><br></div><div><font face="monospace"># This is a combination of 3 commits.<br># This is the 1st commit message:<br><br>Replace MPIU_REPLACE with MPI_REPLACE<br><br>Since we believe all MPI implementations support MPI_REPLACE<br><br># This is the commit message #2:<br><br>SF: add an MPI_Op argument to SFBcast<br><br># This is the commit message #3:<br><br>SF: rename SFCreateEmbeddedSF to SFCreateEmbeddedRootSF<br><br># Please enter the commit message for your changes. Lines starting<br># with '#' will be ignored, and an empty message aborts the commit.</font></div><div><br></div><div>4) Edit the commit message as you want, save and exit, done!</div><div><div><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021 at 6:19 PM Blaise A Bourdin <<a href="mailto:bourdin@lsu.edu" target="_blank">bourdin@lsu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
This is not technically a petsc question. <br>
It would be great to have a short section in the PETSc integration workflow document explaining how to squash commits in a MR for git-impaired developers like me.<br>
<br>
Anybody wants to pitch in, or explain me how to do this?<br>
<br>
Regards,<br>
Blaise<br>
<br>
-- <br>
A.K. & Shirley Barton Professor of  Mathematics<br>
Adjunct Professor of Mechanical Engineering<br>
Adjunct of the Center for Computation & Technology<br>
Louisiana State University, Lockett Hall Room 344, Baton Rouge, LA 70803, USA<br>
Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 Web <a href="http://www.math.lsu.edu/~bourdin" rel="noreferrer" target="_blank">http://www.math.lsu.edu/~bourdin</a><br>
<br>
</blockquote></div>
</blockquote></div>