Skip to content

Instantly share code, notes, and snippets.

@cullylarson
Last active March 19, 2018 17:41
Show Gist options
  • Save cullylarson/70eb07617544620a95434860711c17cf to your computer and use it in GitHub Desktop.
Save cullylarson/70eb07617544620a95434860711c17cf to your computer and use it in GitHub Desktop.
Pushing to a client's git repo

Pushing to a client's git repo

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).

Creating the for-client branch

  1. Checkout the very first master commit:
$ git log --pretty=oneline  master | tail -1
$ git checkout <the hash>
  1. Create a branch off of that commit:
$ git checkout -b for-client
  1. 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."
  1. Look at git log to make sure the branch only has the initial commit and the merge (you should only see two commit messages).

  2. Push the branch.

Pushing new changes in the future

  1. Checkout the branch
$ git checkout for-client
  1. 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."
  1. 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
  1. Maybe make changes and do an --amend commit.

  2. Look at git log to make sure the branch only has your merge (you should only see commit messages from these kinds of merges).

  3. Push the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment