Вы должны перебирать внутри объекта с помощью цикла for:
for(var i in foo){
alert(i); // alerts key
alert(foo[i]); //alerts key's value
}
Или
Object.keys(foo)
.forEach(function eachKey(key) {
alert(key); // alerts key
alert(foo[key]); // alerts value
});
The submodule approach is good if you want to maintain the project separately. However, if you really want to merge both projects into the same repository, then you have a bit more work to do.
The first thing would be to use git filter-branch
to rewrite the names of everything in the second repository to be in the subdirectory where you would like them to end up. So instead of foo.c
, bar.html
, you would have projb/foo.c
and projb/bar.html
.
Then, you should be able to do something like the following:
git remote add projb [wherever]
git pull projb
The git pull
will do a git fetch
followed by a git merge
. There should be no conflicts, if the repository you're pulling to does not yet have a projb/
directory.
Further searching indicates that something similar was done to merge gitk
into git
. Junio C Hamano writes about it here: http://www.mail-archive.com/git@vger.kernel.org /msg03395.html[127 provided
Here are two possible solutions:
Either copy repository A into a separate directory in larger project B, or (perhaps better) clone repository A into a subdirectory in project B. Then use git submodule to make this repository a submodule of a repository B.
This is a good solution for loosely-coupled repositories, where development in repository A continues, and the major portion of development is a separate stand-alone development in A. See also SubmoduleSupport and GitSubmoduleTutorial pages on Git Wiki.
You can merge repository A into a subdirectory of a project B using the subtree merge strategy. This is described in Subtree Merging and You by Markus Prinz.
git remote add -f Bproject /path/to/B
git merge -s ours --allow-unrelated-histories --no-commit Bproject/master
git read-tree --prefix=dir-B/ -u Bproject/master
git commit -m "Merge B project as our subdirectory"
git pull -s subtree Bproject master
(Option --allow-unrelated-histories
is needed for Git >= 2.9.0.)
Or you can use git subtree tool (repository on GitHub) by apenwarr (Avery Pennarun), announced for example in his blog post A new alternative to Git submodules: git subtree.
I think in your case (A is to be part of larger project B) the correct solution would be to use subtree merge.