<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  I tried the multiple clone approach first but found I was constantly thinking I was in a different branch than I was in as I went between clones and messing up my working directory and getting confused and frustrated. So I developed some of my tools because I was unable to utilize my brain and working memory to work essentially at all with a multi-clone environment. If one can handle a multi-clone environment then parts of my tools are not needed.<div class=""><br class=""></div><div class="">  Scripts like "git mr" that open an MR (new or already existing) to the branch I am currently in in my terminal window save me having to hunt around with the browser. It also correctly selects either release or main to merge into which saves me endless time since I would always forget when doing everything from the GUI to set release branches to merge off release. Anyone can adopt this script.I had similar things for managing the non-MR pipelines but since no one uses that approach any more they are not useful, I need to update them for MR pipelines.</div><div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 19, 2021, at 1:36 AM, Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com" class="">patrick.sanan@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Cool - I didn't know about this approach - If you still have your experiments sitting around, can you put numbers on what kind of space savings are we talking about vs the dumb approach (I have an independent clone for every branch I'm interested in working on simultaneously)?<div class=""><br class=""></div><div class="">@Barry - thanks for the reminder about that script - even if I don't use it regularly it's good to know it's there to raid in the future when I'm pushed in desperation to start scripting things. </div><div class=""><br class=""></div><div class="">Re the related shallow/"blobless" clone stuff I was posting about [1] - it's fun and work-adjacent (hence in #random) to read about and good to be able to pull out of your pocket when some pathological repo comes along, but the boring truth is that because it's another syntax to remember (or script) and there's a minor inconvenience in the usage (I don't like the way it behaves when you need to fetch something missing, and there's no internet connection), I'll likely never use the feature in my normal workflow. The robustness, simplicity, and google-ability of the dumb way are too attractive!</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><div class="">[1] <a href="https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/" class="">https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/</a> </div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">Am 19.05.2021 um 05:54 schrieb Scott Kruger <<a href="mailto:kruger@txcorp.com" class="">kruger@txcorp.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><br class="">Ahhhh.  I remember your email about it, and I even have it checked out.<br class="">I didn't get it at the time, but necessity is not only them other of<br class="">invention, but of learning.<br class=""><br class="">Scott<br class=""><br class="">On 2021-05-18 18:39, Barry Smith did write:<br class=""><blockquote type="cite" class=""><br class="">  Scott,<br class=""><br class="">    My solution to working with multiple PETSc branches without the agonizing pain is <a href="mailto:git@gitlab.com" class="">git@gitlab.com</a>:petsc/petscgitbash.git <br class=""><br class="">    One could argue it is too particular to Barry's specific workflow but perhaps it has ideas/code that can be stolen for others. It could also potentially be done using the gitlab python bindings and thus remove the direct use of the rest full interface.  I have been using it for about a year and a half and probably for about six months it has been pretty robust and stable. A reminder of its approach<br class=""><br class="">#  An alias for git that manages working with multiple branches of PETSc from the command line<br class="">#    This is specific to PETSc and not useful for any other respositories<br class="">#<br class="">#    Replaces some actions that normally require cut-and-paste and/or (manually) opening the browser to <a href="http://gitlab.com/" class="">gitlab.com</a><br class="">#<br class="">#    + Sets the PETSC_ARCH based on the branch name<br class="">#    + Preserves compiled code associated with the branch checked out when changing branches<br class="">#    + Updates lib/petsc/conf/petscvariables with the branch values so, for example, you can compile in Emacs without knowing the PETSC_ARCH in Emacs<br class="">#    + Creates new branches with the name ${PETSC_GIT_BRANCH_PREFIX}/DATE/yourspecificbranchname<br class="">#    + Adds /release to branch name if created from release branch<br class="">#    + Can checkout branches based on a partial branch name, if multiple branches contain the string it lists the possibilites<br class="">#    + Submits branches to pipeline testing from the command line<br class="">#    + Checks the current branches latest pipeline test results (and optionally opens the browser to the pipeline)<br class="">#    + Opens new or current MR without cut and paste from the branches<br class="">#<br class="">#    Oana suggested the idea to save waiting for code to recompile after changing branches and the use of touch<br class="">#    to force code to not get recompiled unnecessarily. This inspired this script which then grew uncontrollably.<br class="">#<br class="">#    Does NOT change the source code in any way, only touches the object files<br class="">#<br class="">#    Does not currently have a mechanism for multiple PETSC_ARCH for a single branch<br class="">#<br class="">#    Requires git higher than 1.8  TODO: add a check for this<br class="">#<br class="">#  Usage:<br class="">#     git checkout partialname<br class="">#     git checkout -                                  check out the last branch you were on<br class="">#     git checkout -b newbranchname [rootbranch] [message]         adds ${PETSC_GIT_BRANCH_PREFIX}, date, and /release (when needed) to new base branch name<br class="">#                                                     The message can contain what the branch is for and who inspired it<br class="">#     git checkout -b newbranchname [main or release]<br class="">#     git pl   [partialname]                          run a GitLab pipeline<br class="">#     git cpl  [-show] [partialname]                  check on status of pipeline<br class="">#     git mr [-f] [partialname]                       open new or current MR for current branch, -f allows MR without first submitting pipeline<br class="">#     git branch -D[D] [partialname]                  deletes branch you may be currently in, extra D deletes remote also<br class="">#     git rebase [partialname]                        pulls main or release as appropriate and then rebases against it<br class="">#     git branches                                    lists branches in MR, in MR as WIP, tested but not in MR and not merged in main with pipeline results<br class="">#     git push [-f] [partialname]                     pushes branch<br class="">#     git fixup                                       commit changes and rebase as fixup in the current branch and force push resul<br class="">#     git mrfixup                                     rebases branch as fixup to remove all commits applied by MR with Apply suggestion<br class="">#     git cherry newbranchname [release]              removes the most recent commit from the current branch and puts it in a new branch off of main [or release]<br class="">#     git pop                                         go to previous branch, before git checkout (like - except handles multiple branch changes in the script)<br class="">#     git diff                                        do git diff HEAD~1<br class="">#<br class="">#     cizappipeline                                   delete all the blocked/manual MR pipelines (appears to only work for project owners?<br class="">#     cibuild  url [-show]                            login into the test machine and build the PETSc version being tested<br class="">#<br class=""><br class=""><blockquote type="cite" class="">On May 18, 2021, at 5:40 PM, Scott Kruger <<a href="mailto:kruger@txcorp.com" class="">kruger@txcorp.com</a>> wrote:<br class=""><br class=""><br class=""><br class="">Relatively recently, I learned about the git worktree feature and<br class="">attached my write-up of how I use it in petsc.   I have no idea whether<br class="">the response will be:<br class=""><br class="">  This has been around since 2015 at least, and you're just now<br class="">  finding out about it?  LOL!<br class=""><br class="">or:<br class=""><br class=""> I can't believe I never heard about it either!<br class=""><br class=""><br class="">Since Patrick recently talked about shallow clones with git on slack, I<br class="">suspect it's the latter (and I didn't hear about this feature from petsc<br class="">dev's which is where I typically gain all my git knowledge).  Basically,<br class="">if you have more than one clone of petsc on your drive, you'll be<br class="">interested in the worktree feature.<br class=""><br class="">The reason why the write-up is a bit long boils down the fact that we<br class="">have the `/` in our branch names.  It makes things a bit more<br class="">complicated compared to my other projects (but is nice for the directory<br class="">structure).  I have not scripted away the complexity either -- I haven't<br class="">reached that level of annoyance.<br class=""><br class="">The reason why I just don't have the rst file as an MR, is because the<br class="">way I have it point to an existing branch seems cumbersome.  Perhaps a<br class="">git guru knows an easier way with some type of detached state or faster<br class="">way of getting the HEAD to point to the right sha in one go.  I'd be<br class="">very interested if someone knows a better method.<br class=""><br class="">Scott<br class=""><br class=""><br class="">-- <br class="">Scott Kruger<br class="">Tech-X Corporation               <a href="mailto:kruger@txcorp.com" class="">kruger@txcorp.com</a><br class="">5621 Arapahoe Ave, Suite A       Phone: (720) 466-3196<br class="">Boulder, CO 80303                Fax:   (303) 448-7756<br class=""><git-worktree.rst><br class=""></blockquote><br class=""></blockquote><br class="">-- <br class="">Scott Kruger<br class="">Tech-X Corporation               <a href="mailto:kruger@txcorp.com" class="">kruger@txcorp.com</a><br class="">5621 Arapahoe Ave, Suite A       Phone: (720) 466-3196<br class="">Boulder, CO 80303                Fax:   (303) 448-7756<br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>