4

I want to keep some commits private on push, so I want that they get bundled into one big commit on the remote side. Locally they should remain splitted.

A use case is for example the work on a static blog. The draft steps should be commited and tracked locally but on push I want only publish released versions.

A solution in git and/or mercurial will be accepted.

1
  • Why do you want to hide them? What about merging with --no-ff and then only following the first-parent of each commit?
    – knittl
    Aug 28, 2012 at 10:31

2 Answers 2

5

In Mercurial 2.1 and later you can use phases to mark changesets as "secret". This will mark all outgoing changesets as secret:

$ hg phase -f --secret "outgoing()"

A secret changeset is not pushed or pulled by default, so after that command there wont be any outgoing changesets — adjust as needed to mark the right changesets as secret.

You also say you want the changesets as one big commit in the remote repository. For that you can use the histedit extension bundled with Mercurial 2.3 and later. Use the --keep flag so that it wont remove the original changesets when you collapse them.

2
4

The idea would be to make your commits on a dedicated branch, but to git merge --squash them on master (or any other public branch you intent to push), since it will produce one big commit.
You would then push master on the remote repo.

See "In git, what is the difference between merge --squash and rebase?"

2
  • Note: squasing commits in Mercurial: stackoverflow.com/a/1725638/6309. More generally: stackoverflow.com/questions/6937776/…
    – VonC
    Aug 28, 2012 at 10:54
  • I think this is the way to go. Keeping a local branch for each article draft phase and then merge --squash a release version in master. Later I can throw the draft commits away if I don't need them. Will try this in practice and then accept your answer if it works :)
    – schlamar
    Aug 28, 2012 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.