Angelo Borsotti
Angelo Borsotti

Reputation: 327

git avoid to push binaries

Suppose I have a private repository and a public one. I develop using my private repository, and at significant steps I do a commit in which I save all, sources] and binaries. The reason for saving binaries is to allow to recover a previously committed version without having then to rebuild all binaries. When I have completed the development of a feature, I push it to a public repository, one that is accessed by an integrator, that takes my contributes and other developers' as well, and integrates all of them. After having pulled all the contributed, the integrator always rebuilds the binaries. Therefore, there is no need for me to push binaries from my private repository to the public one, and for him to pull them. Is there a way in git to avoid to push and pull binaries in this workflow?

Upvotes: 3

Views: 1382

Answers (5)

rgngl
rgngl

Reputation: 5423

You can try building the binaries in a separate directory. Then you can treat is as another local repository and keep your source repository clean from binaries. Having them in your local repository and avoid pushing specific files to the remote repository would defeat the purpose of a DVCS.

Upvotes: 0

Darryl Miles
Darryl Miles

Reputation: 4631

I don't think what you exactly want is possible. You want 2 remote repos, but push binaries to one of them and never the other. I do not think that will be possible without resorting to using special commands (with options to ignore .gitignore files when making a commit) for the repo to push binaries.

Take a look at the .gitignore feature to ignore files from commits (and therefore pushes). But this isn't exactly what you want since it will stop all binaries from being pushed.

Beware checking in binaries to git as all checkouts will update the timestamp of the binary (which can be newer than the other files in your project and therefore incremental builds do not rebuilt things, since many tools use file timestamps to work out what to rebuild).

The problem for you is that in order to push anything you must commit it. But both repos will see all commits for the branch they share and distribute.

So the only work around for you is to create a new branch in your local working copy (and in your private repo) and this branch will only have commits of the binaries. But this is much work and headache for you to sort out and implement.

i.e. youi need to setup a workflow to switch branchs to this binary only branch, then search for all binaries, then produce a commit (possibly ignoring .gitignore or editing), then push to private repo, then undo any changes made to repo (recover old .gitgnore if you edited it), then switch back to original branch containing only source code.

My advice would be to reconsider why you need to push binaries. Does your project rebuild take many minutes/hours ?

Upvotes: 0

Neil
Neil

Reputation: 55432

One approach would be to have two repositories, your source respository and your binary repository. Clone the source repository as a submodule of your binary repository so that you can associate a particular source revision with your binaries.

Upvotes: 1

Jiri Kremser
Jiri Kremser

Reputation: 12857

In short, name the directory with binaries in:

.gitignore

Upvotes: 0

michel-lind
michel-lind

Reputation: 9776

What the Fedora project does is to have a look-aside cache, in which binaries are checked in and identified by their checksums -- if you don't need the binaries, simply ignore the file that list the checksums and corresponding file names

Upvotes: 1

Related Questions