I'm using git for a PHP project, I think it's really handy. There is one thing that would be great if I get it to work.
I have created a branch, meant for deployment. It has some differences, like different configuration files and documentation.
I can't just ignore them, because then they will stay in both branches, while I would like to keep them different in both branches.
The problem is that when I merge the branches, those files that are meant to be different are merged too.
Is there any convenient way to accomplish such a thing? How is this normally done?
Just go to Overview => latest activity => Search for latest deployed item => Click compare diff on that item => Click on one commit => Check the branch there.
Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch. Simply use a git push origin command on subsequent pushes of the new branch to the remote repo.
The developers in the team constantly commit their work into a single, central branch—which is always in a deployment-ready state. In other words, the main branch for the project should only contain tested and quality work, and should never be broken.
Update Feb. 2021: Git itself is still not a good fit, but GitHub Action environment could help.
2009: I am not sure Git is meant to be used this way.
First a quick Linus advice, always "colorful" and informative ;)
Git very fundamentally tracks project state, not file state. Which means that you very much can NOT try to "merge a file". It is a senseless operation in git, and in fact, any SCM that allows it pretty much is doomed to be a total piece of sh*t (*).
(*) And I'm not saying that just because git doesn't do it. It's much more fundamental than that. Once you start doing per-file branching and merging, you've basically screwed yourself, and you'll never be able to work on the project as a "whole project" any more - you no longer have a well-defined history that actually is the history of the whole project.
There.
That said, you could:
Other solutions in this thread involve working on a "server-specific" branch on your deployment server
Development Deployment #origin/master: x--x $ git clone # master x--x $ git checkout -b deployment origin/master x--x \ -- #deployment $ .... #makes changes for config files #or other specific deployment files x--x \ --d1--d2 # no need to push that branch ever. #new developments x--x--x--x $ git pull --rebase #pull origin/master and #replay current branch on top of it x--x--x--x \ --d1'--d2' #SHA1 rewritten in deployment branch #not important since this branch #is not pushed (published)
I do some silly tricks like:
config
config.development
and config.production
but not config
to the repositorycp config.production config
Does that make any sense?
It works okay for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With