[fpc-devel] Submitting patches using git

Martin Frb lazarus at mfriebe.de
Sat Jul 20 22:52:38 CEST 2019


On 20/07/2019 22:14, Ryan Joseph wrote:
>
>> On Jul 20, 2019, at 4:02 PM, Martin Frb <lazarus at mfriebe.de> wrote:
>>
>> "origin/master"   is the not modified trunk?
> No, what I did was fork https://github.com/graemeg/freepascal and then a create new feature branches based on master. “origin” I believe refers to my forked repo on GitHub and “upstream” is the original, i.e. https://github.com/graemeg/freepascal.
>
> So what I do when I want to keep up to date is "git pull upstream master” which updates my local “master” branch with changes from graemeg/freepascal. The problem I face now is how to get changes from master into my feature branch. Merging worked fine but then I face the problem of not being able to squash all commits before submitting patches. I’ve just learned now that rebase works BUT I need to squash commits first. Catch 22.
>
> The real root of the problem is that I need to squash my feature branches commit history or my patches will get rejected. If that weren’t the case I would just do a merge and release the patch with full commit history.
>

Ok there are 2 questions

1) if you pull, and want to avoid merges.

git pull --rebase

will rebase instead of merge.
BUT: if you push your resulting branch to your own repro then you may 
need force-with-lease. That is if you had already pushed before, because 
then you need the same history rewrite on your server, as you did 
locally with the rebase.

forced push should only ever be to your own repro/server. And ideally 
always force-with-lease



2)
You current branch.

You can rewrite your current branch

Again find the first commit you made, that is of interest. Get the hash 
of the commit ONE BEFORE "0abcedef"

Whilst checked out to your branch:
git rebase -i 0abcedef

Should open an editor with all the commits in it.
Re-order them, so ALL your commits are on top.
The editor text has some doc in it. You can squash your commits now. But 
you can do that later, and keep the unsquashed ones too.
Save and exit the editor.

git will rewrite the current branch, to have commits in the order that 
you specified.

------------------
If you want to play: Before you start, create a new branch at the top 
(HEAD) of your current branch.
That will keep the old commits in the old order under that new branches 
name. (reflog does the same, but this may be easier)




More information about the fpc-devel mailing list