I'm a freelance programmer. Sometimes I work on projects where the client wants
to occasionally see code updates in their own repo, but I don't want them to see
my work schedule. If I push my dev repo, they'll see when I'm working, how many
hours, etc. To solve that, I started maintaining a for-client
branch that
only shows weekly, squashed merges of master. Each commit is monolithic, with
one commit message (it doesn't include all of the individual commit times, messages,
etc. from the master branch).
- Checkout the very first master commit:
$ git log --pretty=oneline master | tail -1
$ git checkout <the hash>
- Create a branch off of that commit:
$ git checkout -b for-client
- Do a squash merge of master onto the new branch, and commit that merge:
$ git merge --squash master
$ git commit -m "Initial push to the client's git repo."
-
Look at
git log
to make sure the branch only has the initial commit and the merge (you should only see two commit messages). -
Push the branch.
- Checkout the branch
$ git checkout for-client
- Do a squash merge of master onto the new branch, and commit that
merge (
-X theirs
just resolves all merge conflicts by using master’s version):
$ git merge -X theirs --squash master
$ git commit -m "Update for client."
- Compare to master to make sure everything is the same (git won’t include file removals in the squash merge, so that might be something to fix):
$ git diff for-client master
-
Maybe make changes and do an
--amend
commit. -
Look at
git log
to make sure the branch only has your merge (you should only see commit messages from these kinds of merges). -
Push the branch.