I'm developing a project, which I'm pushing to private repository on my VPS. However, I'd like to publish it on GitHub.

I make a lot of commits(mostly as backups) which doesn't contain complete implementation of feature. I do not want to include history of these commits in public repo.

So, private history would look like:

  1. Initial commit
  2. Part Feature A
  3. Part Feature A
  4. Part Feature A
  5. Finished Feature A
  6. Part Feature B
  7. Finished Feature B
  8. ... etc ...

And desired history of public repo would look like:

  1. Initial commit
  2. Feature A
  3. Feature B
  4. ... etc ...

And there must be no track about partial commits made for development backup. So all internals of a GIT repository would look like there were only just Feature commits, no partial commits.

I know, that I can clone repositories to different folders, and copy-paste between these folders. However, GIT is designed for distributed development. So, I'm wondering whether there's some cleaner and more GIT-like way to solve this.

How to manage separate repositories with different histories?

The first commit on public repo can be completly squeezed, but since then I would like to have a nice commit history in public repo.

  • 1
    Do you need to maintain the multiple smaller commits in a private repo?
    – user40980
    Commented Nov 10, 2015 at 16:50
  • What's the actual reason for wanting to only expose completed features? If it's so people can easily check out specific good checkpoints, you could just tag the completed commits and otherwise leave everything as it.
    – 8bittree
    Commented Nov 10, 2015 at 16:54

2 Answers 2


Use the Gitflow Workflow

Following this model, the master branch contains only releases, the develop branch contains the WIP (work in progress) commits, and feature branches are used to develop features.

The main benefit of this approach is, if you screw up and publish a bad commit to develop you'll be able to rollback the changes without screwing up the the history of the publicly accessible version on master.

So, that doesn't answer your question...

What about combining partial features into a single feature commit?

Simple, before merging a feature branch into develop squash the commits using interactive rebase.

git rebase -i feature-branch

It'll pop up an editor and you can change which commits you want to squash. It also concats the commit logs so you can add all/part of them into the squashed commit message.

Note: There are many ways to squash commit history. IMHO, I think interactive rebase is the most straight-forward but YMMV.

When you're ready for a release, simply create a release branch from develop and merge the release branch into `master.

Developing features can be challenging because a maintainer may require a contributor to make additional changes piecemeal prior to accepting a PR (pull request).

Using the strategy above, the contributor will still have a granular history containing all of the changes made to the feature throughout development. This makes it easy to roll-back and/or cherry-pick commits individually.

Note: The ability to cherry-pick commits is extremely valuable if the contributor runs into complicated merge conflicts.

If you want features to commit cleanly, simply have the contributor squash the changes as the last step prior to a merge.


This begs the question of why you want to do that, but that is your problem. Here are some possible approaches to do that:

Separate branches for features

  • Keep your master branch in sync with master of the public repository
  • develop each feature in your local / private repository, but do not sync these branches with the public repository
  • use git merge --squash to merge these branches as a single commit

Using different repositories

  • Use a repository for public and private development
  • develop in your private repository
  • after a feature is done, use git diff to create a .diff file
  • apply that diff using patch in the public repository and commit.
  • What does the first approach in "simple English"? "Converts branch (series of commits) to single commit?" Could you please provide step-by-step tutorial with explanation. Somehow, I don't get it :(
    – kravemir
    Commented Nov 10, 2015 at 17:58
  • 1
    @Miro the "how do you do squash a series of commits into a single one" would be a question to ask on Stack Overflow instead. It delves a bit too deeply into the specifics of commands and the use of the tool rather than the higher level workflow. See Where does my git question go?.
    – user40980
    Commented Nov 10, 2015 at 23:08
  • @Miro This is an example for how squashing commits works, rebase or merge is more or less the same: gitready.com/advanced/2009/02/10/…
    – Residuum
    Commented Nov 10, 2015 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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