[llvm-dev] Workflow to commit changes using git alone (?)

Joan Lluch via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 8 08:46:23 PST 2019

Hi Melanie,

I would have hoped for a more automatic way, but I will give “--amend” a try.

Thanks for that!


> On 8 Nov 2019, at 17:36, Blower, Melanie <melanie.blower at intel.com> wrote:
>> -----Original Message-----
>> From: Joan Lluch <joan.lluch at icloud.com>
>> Sent: Friday, November 8, 2019 11:29 AM
>> To: Blower, Melanie <melanie.blower at intel.com>
>> Cc: llvm-dev <llvm-dev at lists.llvm.org>; Sanjay Patel <spatel at rotateright.com>
>> Subject: Re: [llvm-dev] Workflow to commit changes using git alone (?)
>> Hi Melanie,
>> Thanks for your reply, but if I understand it well, this implies making changes to
>> the local ‘main’ branch, and push from that, which is what I want to avoid. But
>> still, if I push from ‘main’, how do I fold a number of local commits into a single
>> one, with a single comment, as appropriate for LLVM?.
> [Blower, Melanie] I'm not a sophisticated git user, but I do know how to fold local commits.  
> % git commit --amend
> Assuming your workspace has several commits and you want to compress then into 1 before push
> This is an interactive process, git will pop you into an editor, maybe 'vi' with a bunch of SHA codes listed. What I do is,
> Keep the top line unmodified, on subsequent lines use the 's' letter to indicate that you want to squash it into the previous
> After you write out the file that git put you into, it will prompt you again to finalize the commit message for the compressed commit. It's all local so you can give it a try.
>> My workflow consists on creating different local branches to avoid changes on
>> the ‘main’ branch. This allows me a couple of things: First, I always keep my local
>> ‘main’ branch in sync with the remote one, so it’s very easy to spot differences
>> with my working ones by just running diff between them. Second, I can do an
>> undo things, or test them in my working branches as many times as I want and
>> commit often. I can even start from scratch from main again by just creating a
>> new branch from that, without ever messing with the ‘main’ branch. Also,
>> separating work into branches allows for implementing another patch while a
>> previous one is waiting review, (while still never touching ‘main’).
>> In the past, I worked using a similar environment on a small team. Everyone's
>> local changes were pushed to the remote repo at the end of the day by first
>> merging into our local ‘main’ and then pushing to the remote ‘master’. This
>> works on a small team because it doesn’t matter if a number of local commits
>> get pushed together. Also everybody is happy to fix conflicts created by others if
>> they happen, as there’s no ‘reviews’ to begin with.
>> In the case of LLVM it’s desirable that every reviewed patch is pushed as a single
>> commit with the appropriate comment. Ideally, I would want to commit and
>> push the difference between a local working branch and the ‘main’ branch,
>> which is what I can’t figure out how do do. I would be surprised if there’s not a
>> simple solution for that.
>> Thanks.
>> John
>>> On 8 Nov 2019, at 16:24, Blower, Melanie <melanie.blower at intel.com>
>> wrote:
>>>> -----Original Message-----
>>>> From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Joan
>>>> Lluch via llvm-dev
>>>> Sent: Friday, November 8, 2019 6:35 AM
>>>> To: llvm-dev <llvm-dev at lists.llvm.org>
>>>> Subject: [llvm-dev] Workflow to commit changes using git alone (?)
>>>> Hi all,
>>>> I have recently given commit access to LLVM and successfully pushed a
>>>> test commit from my local master branch.
>>>> However, I can’t find which is the recommended workflow for
>>>> committing more serious stuff using git alone. I have read the docs
>>>> but everything seems to still require svn before bridging to github.
>>>> I want to use git alone to commit a patch that I got reviewed.
>>> [Blower, Melanie]
>>> I recently made my first commit to llvm using git, I can't speak to whether this
>> is recommended flow. First get code review and approval, then:
>>> git clone https://github.com/llvm/llvm-project.git ## get the llvm
>>> tree ## apply your patch, test your patch Git add ... files Git commit
>>> ... commit message should include url to the phabricator review Git
>>> pull --rebase ## if your clone is behind master, do this to pull in
>>> the changes neatly Git push ## This will prompt you to provide github
>>> identity
>>>> I currently have a local 'master' branch that I keep identical to the
>>>> upstream branch. I also have another local branch (let's call it
>>>> 'patchbranch' for the purposes of this question) where I committed
>>>> the changes for the patch I want to push. I created the diff file by running git
>> diff to compare my local 'master'
>>>> with 'patchbranch’ branches and uploaded the file to Phabricator. I
>>>> got the patch reviewed and I want to commit it now to the upstream
>>>> master. I make sure my 'patchbranch' catches all the upstream changes
>>>> by pulling from 'master', merging 'master' into my 'patchbranch and running
>> the relevant tests.
>>>> I want to push my local 'patchbranch' to the upstream ‘master’ in
>>>> GitHub without affecting my local master branch. I also need to make
>>>> sure that my patch is pushed as a single commit. I do not want to
>>>> merge my local 'patchbranch' into my local 'master' because I want to keep
>> my local 'master'
>>>> clean and always identical to, or only slightly behind, the upstream branch.
>>>> I have read the documentation but all the described workflows seem to
>>>> imply the use of svn at some point, which I do not want to, or know
>>>> how to use. I understand this is a basic question but I used git
>>>> before with small teams only, so a detailed workflow for LLVM commits using
>> git alone would be appreciated.
>>>> Thanks,
>>>> John
>>>> _______________________________________________
>>>> LLVM Developers mailing list
>>>> llvm-dev at lists.llvm.org
>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

More information about the llvm-dev mailing list