This question is more of an application architecture and source control type of question.
I have 2 Github repositories, one is a React single page application and the other is for a React website. For my single page application, I am making the code publicly available and the application links to its repository. For my website, I want to keep the repository private but incorporate the single page application into it so people can use it without having to download and build code.
Can I get some options on how to merge changes to the single page application repository with the website repository?
So far I am just merging code to the website manually by copying it over and pushing the code, but that is a problematic way of doing things. Neither repo is completely up and running yet, so there is still time for me to make architecture changes. Maybe there are git commands to handle everything?
Any help is appreciated, including suggested architecture/repo changes.
I think the best option here would be to use git cherry-pick, but in an automated way:
Build a simple script that listens for push events via git webhooks, from your single page repo. That way you can get the merge-in-master event automatically
Get the hash of that commit
Plug that hash into the git cherry-pick command applied on your private website repo. You can apply this commit on a separate branch in this repo, and merge it in master when you think it's appropriate
Related
I and a friend want to work on same project but we are in different location.
I will be working on backend while he will be working on frontend.
How do I feed him with my backend API. What's the best solution, app or tools to use.
Strongly recommend using git as a collaboration/version control tool. You can sign up for free at github.com and they now support private repositories. There's a bit of a learning curve, but git is highly adopted and one of the standards for managing code between several 100s or even 1000s of contributors across large projects.
Some of the basics:
1) think of git as a way to share code between developers
2) not only that, but you can manage change history and track changes over time
3) seamlessly manages most changes, enabling you and your team to view point-in-time versions
Check out the Git handbook at https://guides.github.com/introduction/git-handbook/ to get started!
To address your specific question:
when you are ready to share your backend code, check it into your git repository and let your collaborators know that updates are available
make sure to include instructions on how to use your backend code; do they run the server locally? is it deployed to a url? is it running in docker or kubernetes? is it authenticated, and how?
they will "pull" your changes and start working against them; when they have updates, they should commit them to git and push to the remote repository. You can then pull down their changes and review the full frontend/backend solution.
You can use these tools to make your life easier
Github or Bitbucket for code collaboration
Postman or Postwoman for API share
Jira cloud or clubhouse for Issue tracking ( free for 10 users)
Confluence for documentation.
Slack for real time communication.
These are tools I am using for collaboration with others. This is just my opinion.
While going through the AngularJS phonecat tutorial (https://docs.angularjs.org/tutorial/step_00), I was very impressed the way the git repository is setup to allow the learner to checkout any particular step and look at diffs between that step and the previous/next step.
I started thinking about how the Git repository would be setup to achieve this.
Initially while creating the tutorial if each step was performed and checked-in and tagged then the repository would allow each step to be checkout and compared against other steps, easy. However, this quickly falls apart when you think the tutorial needs to be kept up-to-date without effecting the diffs between steps and also updating all the steps to use newer code or libraries.
Can some git ninja explain to me how they have achieved this. I see several branches and many check-ins to update to new version in their repo (https://github.com/angular/angular-phonecat). But the updates do not effect the learners view of the steps and the diffs between them. How?
I think the tutorial make use of tags to mark the commits in the project, you can type git tagand you will see a list of steps from step-0 to step-12.
you can make use of tags to mark your commits by using git tag [tag name] in your current working directory and the tag will point to your current commits.
Hope my explaination is clear enough that you can make use of it.
Btw The phonecat tutorial is really good.
What is the decision tree to know when to split a suite of related and/or cohesive applications into git repo's and/or branches? Should I keep each app in a repo? Or all app's & dependencies in a single repo? Or something in-between?
answer How should I organize multiple related applications using git? claims that a repository per project is appropriate, but does not give clues as to what a project would be.
And then there's the question of dev, test, integration test, and production checkouts when the git repo's are split. Answer how do you organize your programming work lists some branch/tag options, but ignores the multi-app details.
There's also the DB schema! incremental definition of the schema helps, but again, where would one keep this definition if the DB spans back-end and front-end app's?
Some examples I've been pondering:
a front-end web app and it's back-end CGI/DB: one repo or two?
a set of web back-ends that use features from other back-ends
a set of front-end app's that share CSS and jquery plug-ins
selenium scripts that test front-end features across dependent code - in the front-end app repo or the dependent code repo?
If I want to work on a single app, it's hard (well, tedious and error prone) to check out a directory of a repo, so I have to check out the entire git tree (or at least clone the whole tree), so that implies that git is not really built for keeping all the app's & dependencies in a single tree.
But if I want to keep each of the projects (app's, frameworks, dependencies, doc trees, CSS) in it's own repo, then I run into chasing my tail for dependency resolution, that is, I don't know which version of each app are compatible. I think git tags are a good way to go, if only I could move them to newer versions that maintain compatibility.
When app's split or merge -- as happens often with refactoring models down to baser models -- can i move the git history of just those files to another git? I don't see how to do this, so that leans towards a single repo for it all.
If I develop a new feature across app's, it would be nice for branches to represent features.
I think I want a repo of repo's -- does that exist?
This is about using a component approach: a component being a coherent set of files which have their own history (own set of branches, tags and merges).
It should include only what cannot be generated (although the db schema can sometime be added to the repo, as seen in "What is the right approach to deal with Rails db/schema.rb file in GIT?". You still can generate it though, as shown in "What is the preferred way to manage schema.rb in git?", to avoid needless conflicts)
A component can evolve without another one having to evolve. See "Structuring related components in git".
That is the main criteria which allows you to answer: "X and Y: one or two repos?".
You can split a repo into two later, but be aware that will change their history: other contributor will need to reset their own repo to that new history.
You can group those different components repos in one with submodules, as explained here (that is the "repo of repos", or, if you want to have only one repo, in subtree, as illustrated here.
I'm looking for a tidy way to manage my cross-platform HTML+JS projects in github.
Here's my typical working process:
I complete developing my app for ios
I start working on Android platform version
I start working on XXXXXXX platform
...
From step 2 and further I come out with:
commits that can be merged in the Head repository
commits that can not be merged, so I have at least 2 versions of some of the files that compose the project
My problem is that forking/branching for each platform force me to duplicate changes on the shared part of the project too. Maybe there's something that I'm missing in both branching and forking.
Which method you use to organize your code on github so as to preserve both the differences and the unity of the project?
It sounds like branches might be the way to go: create an android branch, etc., and if you need to branch those further then create android/branch1, android/branch2 and so forth.
When you need to merge files between branches you might want to use the git cherry-pick command to select the commits to merge. I would also probably do this on a temporary local branch before pushing, to make it easy to recover from screw-ups!
I made a simple CMS with CakePHP to handle a small (but growing) number of websites. The CMS is constantly evolving as I regularly add features to a development version on my own machine.
I use SVN to trace the evolution of this development version, and that's pretty much it. To make a new website, I basically copy/paste the dev folder and modify the necessary files before uploading the new website by FTP.
One problem is in the end, every website installation is independent and if I want to add some new features to existing websites, I have to copy files by hand.
Another problem is that some websites have modified versions of the CMS because of specific needs: some controller classes have specific methods not present on the local version.
To sum it up:
I have one base CakePHP app regularly evolving
There are multiple versions (=websites) of this app already installed on different servers
Some websites have custom code included not present in the base version
I want to be able to easily update all the present and future websites when I improve the base app, without breaking some possible specific parts
Knowing it's a CakePHP app, what would you do? How should I change my code to manage at the same time the core and the specific code?
Thanks in advance!
... some controller classes have specific methods not present on the local version.
You might also consider the option of setting up additional class paths within each of your website applications. You can tell CakePHP to check other directories entirely for files missing from the current application. For example, you could have the following directory structure:
/app1 - a standard client's website application
/app2
/app3 - a custom client's website application (with custom controller)
/core - the core CMS application
/cake
By adding the following to your /appN/config/bootstrap.php files, you are telling CakePHP to look for controllers in /core/controllers if it can't find one it's looking for in the current application.
App::build(array(
'controllers' => array(ROOT . DS . 'core' . DS . 'controllers' . DS),
));
This would, for example, allow you to put all your CMS controllers in /core/controllers and delete all your /appN/controllers directories. Only where a client needed a controller customized (ie. /app3 above) would you create a controllers directory, copy the specific controller across and make modifications (adding methods and such).
(This is the approach the developer of Wildflower CMS took - note the /wildflower directory.)
Using version control software (like SVN) would probably do the trick for you. Each website you work on could be a branch that follows the main branch of development. Every time you make a change that you want to apply to every site, you'd update the main branch and then have every sub branch import the changes from the main branch.
Mind you, I'm more used to how Git works, so this scenario might work better in Git than in SVN, ymmv.