I have a gerrit repo with a submodule:
parent
submodule
Now I make some change to submodule and want to push that to gerrit. Unfortunately the submodule is set up only as a git repo, not a gerrit repo, because gerrit repo has remote url that contains my username, thus cannot be checked into the .gitmodules file. So is there a convenient way to set up the submodule also as a gerrit repo when I clone parent?
So far my colleagues have all told me to patch whatever change in the submodule to a separate gerrit cloned copy of the submodule. But this seems rather inefficient. I see no reason why gerrit remote urls should not be propagated to all the submodules, recursively. Thanks!
I'm not sure if I understood your question correctly, but you don't need to add your username in the repository remote url in the .gitmodules file. Just use something like that:
url=https://GERRIT-SERVER/a/REPO-PATH
When the username is not mentioned the default USER will be used.
Related
It's possible with git submodules to checkout multiple repositories as submodules into respective paths, e.g.:
% git submodule add git#.../repo1.git ./here/is/1
% git submodule add git#.../repo2.git ./here/is/2
But what if I need to checkout the contents of repo1 and repo2 both into a single path, ./here/is/3?
Basically I have a metric shit-ton of submodule repos I need to all be checked out into a very rigid directory hierarchy on the client side when the user does git clone --recursive ...
I want the contents of all submodules to be checked out into ./somepath. Can it be done?
One thing I considered was using symlinks, but that feels wrong.
EDIT:
I want the contents of 1 and 2 in the above to be placed in the same target directory on the client. I can do this by having the user manually run a script after cloning (it is not possible to have git track a single file), but it seems like there should be a cleaner way to do this -- manually creating a symlink for each submodule is a lot of work, and it seems like the submodule abstraction should be able to handle this.
Maybe my question is a dupe-in-disguise?
One way would be to create another parent repo, with the submodules declared directly in it:
newParentRepo/
1/
2/
3/
...
That parent repo could be cloned --recursive in ./somepath, and the submodules would be directly under ./somepath (in their respective root directories 1/, 2/, ...).
You would need to synchronize the SHA1 of the submodules as recorded by the first parent repo into the second parent repo, in order for said second repo to record the right list of submodules SHA1.
I need to switch from Composer (which is used by Symfony2 by default) to Git submodules.
I thought I could just add the desired submodules to the desired locations, thus overwriting the current version which was installed by Composer.
But when I use git submodule add, it says:
'vendor/twig/twig' already exists in the index
So I tried:
git rm vendor/twig/twig
and tried to add the submodule again, same error.
What am I doing wrong?
I'm founder and ceo of cloudControl. Currently composer does break our image building process because it interferes with the logic we have to detect submodules in some way. The team is aware of this problem and working to fix the underlying issue.
I'm working for cloudControl and we've been lately inquiring into this issue.
Regarding the original problem, you proposed already a right solution for replacing the composer packages by git submodules, it was just a git commands issue. But doing this doesn't make much sense, as long as these git submodules are identical to the Composer packages and your php code is still hanging on the autoload.php provided by Composer.
We don't process internally Composer yet, their files are just added into the repository and the php code requirements make the rest. However we do process git submodules, so if you want to make a real switch from Composer to Git Submodules, the best option is getting rid of Composer files (vendor folder and composer.* files), adding git submodules wherever you want and handling again the php dependencies . Thus everything should work fine and you'd have switched completely to git submodules.
Native support for Composer is in our future plans.
The problem was that i had to actually delete and git-remove the repository first.
i.e. for twig what i did in the end was:
git rm -r vendor/twig/*
rm -r vendor/twig/*
git add vendor/.
git submodule add git://github.com/fabpot/Twig.git vendor/twig/twig
git submodule add https://github.com/fabpot/Twig-extensions.git vendor/twig/extensions
Now i have twig and twig extensions as a git submodule and can use it in my cloud application.
I am trying to use git svn to connect to our company repository. We have a slightly non-standard branches directory. How to access this using git svn has been discussed before, however, we seem to have a slight twist in our branch names that seems to keep me from getting them all.
Let's consider an example svn repo:
trunk/
tags/
branches/
rootbranch/
tku/subbranch
We have branches at the root level of the branches directory. But we have branches in nested folders, as well. The same goes for the tags dir, but I think that is just a second example of the same problem.
If I use git svn clone file:///tmp/gitsvn/svnrepo git-clone -s, I get only the root branches, as expected:
/tmp/gitsvn/git-clone$ git branch -r
rootbranch
tku
trunk
But if I clone using _git svn clone file:///tmp/gitsvn/svnrepo git-clone2 -b branches//_, I get only the sub-branches:
/tmp/gitsvn/git-clone2$ git branch -r
tku/subbranch
Is there a way to have both?
Additional branches can be accessed by adding multiple branches lines to the git-svn config.
In the .git/config file, there will be a section similar to the following:
[svn-remote "svn"]
url = http://server/svn
fetch = trunk:refs/remotes/trunk
branches = branches/*:refs/remotes/branches/*
tags = tags/*:refs/remotes/tags/*
Simply add another entry for the extra directory of branches. For example:
branches = branches/tku/*:refs/remotes/branches/tku/*
Then run git svn fetch to retrieve the branches from the svn repository.
I believe it's also possible to create this setup when constructing the git repository, using multiple -b options to the clone command.
git svn clone http://svn.foo.org/project -T trunk -b branches -b branches/tku -t tags
For anyone else who stumbles over this: it seems that having both is not possible. Subversion allows a mixed setup of branches, but it is discouraged, and so it seems okay that git does not support this. My solution was to bring all branches to the same level, then forget about the issue and move on. Having only one level of branches seems better anyway.
Is there any way to use git-svn to clone only some folders of an SVN repo structure. I'm trying to clone a repo that has some crazy big binary files and a number of subfolders that are just plain useless. I've tried using the --ignore-paths option, but my clone seemed to just stall out doing nothing for an extremely long time. Have any of you managed to make --ignore-paths work? I can't find much on the webs where anyone else is running into this. Maybe I'm the only one.
We've used the "ignore-paths" feature to ignore certain directories in a svn repo:
[svn-remote "svn"]
ignore-paths = ^(((branches|tags)/[^/]+|trunk)|)(huge/|mobile/)
This config ignores the "huge" and "mobile" subdirs of the repository in trunk, all branches and all tags.
Perhaps you can illustrate the structure of your Subversion repository to make it easier for us to suggest some solutions.
Are you trying to git svn clone the entire repository from the root-url? Have you tried cloning smaller parts of the repo, and then perhaps grafting several clones together?
The most success I've had here is to manually create branches in git that mirror the SVN remote repository when necessary. The process has been the following:
Update .git/config file with:
[svn-remote "svn-branch-alias"]
url = http://svn/branches/crazybranchname/craziername/url/
fetch = :refs/remotes/git-branch-name
From the command line type: git svn fetch 'svn-branch-alias' to collect the SVN branch data into your local git repo.
Then type: git checkout 'git-branch-name' to go into a headless mode.
Finally type: git checkout 'my-local-git-branch-name' to create move head to the latest submission in that branch and create a local branch alias you can use.
You can now commit and dcommit as usual and still switch between various local git branches and your manually created SVN mirrors using the usual mechanisms.
Is there a way to use Github and Unfuddle for the same repo? I am responsible for a repo hosted at Unfuddle, but I am not the main owner and it's private because it's part of an ongoing project. I still need to update the repo there when changes are made, but I would like to use the same set of files to create and update a public Github repo associated with my own account, is that possible? The reason I want to use the same files is that it's a WordPress plugin and it needs to be tested before I commit changes, therefore I need to use one set of files to not complicate the matter. Any help would be appreciated.
You can set up both the repositories as remotes and push/pull to and from both of them; Git is decentralized and thus doesn't really care about whether you have one remote or many.
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
Example:
git remote add github git#github.com:username/reponame.git
and then...
git push github <branchname>
git pull github
git log github/<branchname>
etc...
Create your github repository, then from your Unfuddle local repository, run:
git remote add github git#github.com:YourUsername/YourReponame.git
Where YourUsername is your github user name, and YourRepository is your repository name. After setting up the github repository, the above URL with the user name and repository name filled in, should appear on your github repository page anyway.
Everything works like you'd expect, for example, pushing:
git push github
Your settings for the Unfuddle repository will work like before.