Maintaining my own branch with git
Steve O'Hara-Smith
steve at sohara.org
Wed Apr 28 12:16:38 UTC 2021
On Wed, 28 Apr 2021 13:49:23 +0200
Andrea Venturoli <ml at netfence.it> wrote:
> Hello.
>
> I know tons of messages have been written on the subject: I read them
> all, along with the Git Primer docs, but somehow I think I'm not doing
> it right and I cannot understand what I'm doing wrong.
>
> I need to have some patches applied to both src and ports and distribute
> them to several machines.
> So I have my own git server and I want to keep my own FreeBSD branches.
>
> I cloned FreeBSD's git repository and pushed into my server; then I
> created my own branches.
OK let's stop there. I would not do that.
I would do this:
1: Clone the FreeBSD repository into my work area
2: Create my branch(es) off freebsd/main like this:
git checkout main
git checkout -b myworkingbranch
3: Apply my patches in myworkingbranch and commit them to that branch
NB: git commit --amend and git rebase -i are your dear friends for
keeping a clean history in your branch.
4: Push myworkingbranch to your server whenever you're done with a commit
Don't push the freebsd branches ever
5: Update main with git pull (while freebsd/main is checked out)
NB: This will *always* be fast forward since you *never* commit to it
6: Update myworkingbranch with:
git rebase main
NB: This will stash your changes, bring in the updates and then reapply
your changes, requiring you to sort out any conflicts that come up.
7: After this rebase you will need to force push myworkingbranch to
your server
Branches in git are cheap, easy and throwaway things make branches
at the drop of a hat to keep separate threads of work separate, make
integration branches to merge them into and test branches to load with
throwaway debug and never think twice about doing it.
--
Steve O'Hara-Smith <steve at sohara.org>
More information about the freebsd-questions
mailing list