2

We are considering introducing Git into our workflow. At the moment, we have a general PHP template that we copy paste for each new project. The copied template then gets extended with modules specific to the project. Sometimes it happens that while working in a project, we do some adjustments that would be good for the template, we then copy paste these back into the master template.

If we were to introduce Git, our master template would be the main repository. Every new project would be a clone of the template (so bugfixes in the template can be pulled down). However, how would you manage pushing changes back to the master template? We can't push all files, because then our master template would be littered with project specific modules.

Is there a way to only push specific commits to a remote repository?

2
  • When you change the template, do you change the one you have copy-pasted and modified, or the original one? That is are you trying to avoid this: "we then copy paste these back into the master template", or the problem comes after this point? Commented Dec 13, 2012 at 10:01
  • At the moment we change the project template and copy paste back into the master template. Perhaps we should just stop this practice and make relevant changes in the master project first and then pull them down. Commented Dec 13, 2012 at 10:04

2 Answers 2

2

You could interactively git rebase the changes that should be applied to the templates onto the upstream repository. For this, the developer doing it would create a temporary branch from the upstream's master, then rebase the desired changes onto it, and push that branch back (if he has push access; otherwise the person who "owns" the template repo has to pull from them or otherwise apply the changes).

See also: Pro Git Chapter on Rebasing

Sign up to request clarification or add additional context in comments.

3 Comments

Nice! So you rebase that one commit that changes the template onto master, and then rebase your work over the new master?
I'm not entirely sure, but you might even be able to merge it. Since those will be rather small changes to the upstream master, compared to "actual" work in the projects, rebase and merge from upstream to the projects will work equally well, only give you different resulting history, so that's a question of how you want your history to look :)
I had always preferred merge to rebase (my moto is that you shouldn't rewrite history!), but now I realize that rebase is actually sometimes the answer!
0

I would not push changes from projects which use the master template. Instead, I would create own project for the master template and this project would be only for bugfixes and new features for the master template. Only this project could push changes to the master template repository and other projects can only pull.

1 Comment

This suggestion is useful, but the problem is how to get this project to take changes made in the middle of some other project to the template they copied from master. That is, without manual patching.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.