2.6 KiB
git
describes how the git setup works
remotes and branches
first, set up the git branches and remotes correctly.
the main
branch tracks ben/infra:main
:
git branch --unset-upstream main
git remote add origin ben https://git.sudo.is/ben/infra
git fetch ben main
git branch --set-upstream-to=ben/main main
the b
branch tracks b/infra:b
:
git remote add origin https://git.sudo.is/b/infra
git fetch origin b
git branch --set-upstream-to=origin/b b
now the .git/config
file should have the following remote
and branch
config sections:
[remote "origin"]
url = https://git.sudo.is/b/infra.git
fetch = +refs/heads/*:refs/remotes/b/*
[remote "ben"]
url = https://git.sudo.is/ben/infra
fetch = +refs/heads/*:refs/remotes/ben/*
[branch "main"]
remote = ben
merge = refs/heads/main
[branch "b"]
remote = origin
merge = refs/heads/b
make a PR
-
commit your work on your local
b
branch -
make PR from
b/infra:b
tob/infra:main
. -
merge it as a squash commit
-
now
b/infra:main
has the squashed commit from your PR, and yourb/infra:b
branch has the original commits. this is the commit that will be published onben/infra:main
(and thegithub.com/benediktkr/infra
mirror). NOTE: theb/infra
repo doesnt havemain
set as its default branch, so to see the changes there in the web ui, you need to select themain
branch. -
this doesnt have to happen right away, but it helps keeping it tidy. update your local clone, and the
b
branch:-
first, pull the squash commit down to your
main
branch fromb/infra:main
.git checkout main git pull origin main
-
rebase your
b
branch, replacing the original commits with the squash commit inmain
:git checkout b git rebase main
-
then you need to force push that to the remote to keep it in sync
git push origin b --force
NOTE: this could probably be improved, somehow. re-using the branch might be the wrong approach
-
-
now the
b/infra:main
branch has the commit that we want to publish onben/infra:main
(and thegithub.com/benediktkr/infra
mirror), but it isnt there yet. this part is easy, just push to themain
branch toben/infra:main
branch (the branch protection rules allow this):git push ben main
-
now its a good idea to go and compare the
ben/infra:main
andb/infra:main
branches (andgithub.com/benediktkr/infra
), they should be the same and have the same commits.