Use detached branch for deployment

I’m about to set up and automated build environment for a client. I want to push the Git repository to the client’s build server, but without complete Git history.

I’m thinking about an approach with git checkout --orphan ci, but it’s unclear to me how to work on a daily basis with a branch setup like this.

  • Jenkins Can't Run xcodebuild from project folder
  • CI with Jenkins: how to force building happen on slaves instead of master?
  • PHPCI Cannot Write to 'config.yml'
  • Blocking a jenkins task until all downstream tasks complete?
  • Setting up Continuous Integration of Protractor using Jenkins
  • Can Hudson be configured to build every revision?
  • Maybe something like this (?):

    • New commits will be created on the master.
    • A feature is finished after several commits.
    • The ci branch is then rebased/merged (fast-forwarded) on the master.
    • ci branch is checked out.
    • The recent commits (which are not pushed to any server yet) are squashed to hide unnecessary history from the client.
    • The ci branch gets pushed to the build server.

    Is that a valid approach and/or does an easier way exists?

  • Push selected commits in Git using SourceTree and git bash?
  • SVN checkout forbidden with all the tools
  • Git cant diff or merge .cs file in utf-16 encoding
  • Code Lens not working properly after interactive rebase
  • What is the most efficient way to push a set of changed commits in to a remote git repository?
  • Using Git branches to maintain subdomains of a website
  • 2 Solutions collect form web for “Use detached branch for deployment”

    One simple way of managing this could be:

    • Work normally on master (or use any other feature branching model).
    • Every time you finish a feature and want to push it to the CI system you:

      • git checkout ci
      • git merge --squash master This will bring all of the changes in master to your ci branch.
      • git commit You will have a pre-populated commit message with all of the squashed commit messages. You can then edit this message to reflect all of the changes in the feature.
      • git push origin ci To send your changes to the CI system.

    There are many branching models out there, but this should be simple enough and give you what you want.

    I hope this helps.

    I’d look at something such as

    As for CI, you’ll probably end up with pretty much the entire branch cloned/checkedout anyway, but unless you’re putting in a bunch of large binaries I wouldn’t worry too much about it.

    Git Baby is a git and github fan, let's start git clone.