updating named git submodules fails with fatal error - git-submodules

I have worked with git submodules in the past. I know the basic functionality.
If I simply used git submodule add <repo-url> <path/to/submodule>, the .gitmodules file would have :
[submodule "path/to/submodule"]
path = path/to/submodule
url = <repo-url>.git
Recently, I had to add a new git submodule to a repository that I was working on. I also found the fancy --name flag that can be used with the git submodule add command, from the man page of git submodule. The add worked fine and my .gitmodules had :
[submodule "<submodule-name>"]
path = path/to/submodule
url = <repo-url>.git
The issue happens when I'm attempting to update the submodule from the remote :
$ git submodule update --remote
fatal: no submodule mapping found in .gitmodules for path 'path/to/submodule'
OK, I can read the log, so I provide the path/to/submodule next :
$ git submodule update --remote path/to/submodule
Submodule path 'path/to/submodule' not initialized
Maybe you want to use 'update --init'?
OK, if you say so ( though I'm sure that the submodule has been properly initialized before already ). Now :
$ git submodule update --init --remote path/to/submodule
fatal: No url found for submodule path 'path/to/submodule' in .gitmodules
I did some experiments on a test repository and found that this happens only when the submodule is 'named'.
Am I doing something wrong with the name thing of the submodule? According to the man page, the --name flag is only applicable for the add sub-command and it does not work with update.
How do I update such named submodules?

Related

Add git submodule using a specific commit number

I'm using git submodule commands to add this FSM repo in my project. I want to checkout a specific release commit. By default the master branch is checked out.
After adding the git repo, when I run
$ git submodule
It gives
d1b66d66cfa95f238a7498465908a262f4b2326a directory_path/fsmlite
The commit number here belongs to a master branch commit. How can I checkout another commit instead, using its commit number?
There might be some other way to do this, but I got the desired commit by
$ cd directory_path/fsmlite
$ git checkout v0.7.1 (this is the branch I wanted to point to)
$ git submodule update
$ cd parent_dir
$ git submodule
+de19ea0a71cb6082fe9311694a27e8f0cc2f972a directory_path/fsmlite (v0.7.1)
which is the specific commit number I wanted

Git Submodule fatal reference is not a tree

Hi I am getting fatal: reference is not a tree: 947a3c67349eb242a8d46d576e544f8129b28cbf
Unable to checkout '947a3c67349eb242a8d46d576e544f8129b28cbf' in submodule path 'modules/webform'
My work station is as follows:
[root]:
.gitmodules
/modules/webform
Inside .gitmodules I have:
[submodule "modules/webform"]
path = modules/webform
url = https://git.drupal.org/project/webform.git
I have gone into modules/webform and git pull I have also git submodule sync, which gives me Synchronizing submodule url for 'modules/webform'. I have even hard reset that directory. I was wondering if there is a way to delete that reference/reset to the newest version? when I git log it gives me that the reference is a bad object.
I had to update my git --version. I was on 1.7, the latest is 2.1 or something.

submodule project not present in `git submodule status` roster and unable to commit from parent as single object

I use git submodule add <GitHubURL.git> to add projects as submodules to a main "parent" project repository.
Parent_Project_repo
- SubA_repo
- SubB_repo
- SubC_repo
- Sub_Problem_Child_repo
As I work in the submodules, I make commits within the Sub*_repo project (per usual, committing whichever files I have worked on). In the parent project, however, usually I am just making a single commit for all the submodules commits. This single commit of the submodule usually shows up like so in the Parent_Project_repo:
I have recently added a submodule which, from the parent repository, displays each individual file in the commit history instead of just accessing all the files/commits in one single "Subproject" commit object.
Of note:
this problematic submodule does not show up in the roster when I
invoke:
git submodule status
It is listed in the
Parent_Project_repo/.gitmodules
Parent_Project_repo/.git/config
file as a submodule & there is a corresponding
Parent_Project_repo/.git/modules/Sub_Problem_Child_repo/ folder.
How can I get the problem child into the roster and able to have all it's commits handled by the Parent_Project_repo as one object?
UPDATE:
The only difference I have discerned with the “problem child” submodule is that it doesn’t have a “historySha” key in the /.git/modules/config file, e.g.:
[atomGithub]
historySha = 1936e4c373c130860a8f92683b517dad713ec37
Also, these commands don't get the Problem child listed in the status:
$ git submodule update --init --recursive
$ git submodule update --recursive
$ git submodule init
...nor showing up on GitHub in the Parent project with a "# e78c392" which indicates I can double click the link and got to that repo instead of a copy inside the superproject (Parent).
If git submodule add <URL> was used to set up a git repository as a submodule within a "super-project" and the submodule is NOT committing within the super-project as a single object (i.e. if, when committing the submodule from within the Super project you are having to commit each individual file from the submodule), then follow these steps to reconfigure:
Save all work in the submodule.
Stage and commit all file changes.
Push all commits to GitHub.
Make a safety copy of the submodule folder if you are cautious
Delete the relevant submodule section from the super-projects .gitmodules file (i.e. remove the listing of the problem submodule).
Stage the .gitmodules changes git add .gitmodules
Delete the relevant sunmodule section from super-projects .git/config.
Run git rm --cached -rf PATH_TO_SUBMODULE where PATH_TO_SUBMODULE is the actual path to the submodule folder.
Run rm -rf .git/modules/PATH_TO_SUBMODULE.
Commit git commit -m "Removed submodule commit message".
Delete the now untracked submodule files: rm -rf PATH_TO_SUBMODULE
git submodule add <URL>
Test to see if a change (fwiw, modify two files) in the submodule is handled as a single object when committing in the super-project.
Success? Delete the safety copy of the submodule project.

Create a svn branch from git when directory structure differs

I created a local git copy of an svn repo with the following commands:
$ git svn init svn://host/path/to/repo/PROJECT/trunk workingcopy
$ cd workingcopy
$ git svn fetch
Now I'm trying to create an svn branch without success:
$ git svn branch -n mybranch -m "Branch for my things"
Multiple branch paths defined for Subversion repository.
You must specify where you want to create the branch with the --destination argument
In .git/config I do not have any entries under [svn-remote "svn"] as suggested in this answer. I tried adding branches = branches/*:refs/* but this tries to create the branch under the trunk:
Copying svn://host/path/to/repo/PROJECT/trunk at r6684 to svn://host/path/to/repo/PROJECT/trunk/branches/mybranch
What do I need to do to create a branch in the correct location?
Okay, so I changed .git/config from:
[svn-remote "svn"]
url = svn://host/path/to/repo/PROJECT/trunk
fetch = trunk:refs/remotes/git-svn
to:
[svn-remote "svn"]
url = svn://host/path/to/repo/PROJECT
fetch = trunk:refs/remotes/git-svn
branches = branches/*:refs/remotes/*
This worked, but I ran into problems trying to access the branch from a git repo on another machine. In the end, I pushed my changes to svn, then deleted my local git repo and cloned it properly this time:
$ git svn clone --standard-layout --prefix=svn/ svn://host/path/to/repo/PROJECT

Incomplete Clone Using Git-Svn

I have an Svn repository at http://svn.domain.com/project that is structured as follows:
trunk/
build_file_1.xml
build_file_2.xml
project_root/
branches/
cc2.10/
cc3.00/
..
cc3.5/
jira-labs-39/
tags/
studio-2.10.0.0/
studio-2.10.0.1/
...
studio-3.4.1.0/
I want to clone the trunk and branches, but I'm only getting the trunk and the first branch. I'm using this command to clone:
git svn clone http://svn.domain.com/project working-dir --trunk=trunk --branches=branches --prefix=svn/
What I end up with is this:
$ git br -r
svn/cc2.10
svn/trunk
I need to do some work on one of the other branches, but can't figure out what I'm doing wrong. Can someone point me in the right direction?
UPDATE
I just noticed the following error at the end of the output stream:
merge-base 7c552afeaba8194137acb95e642a2222db801dad c40b790b610dc43da93de5328832b1f852a14ef2: command returned error: 1
I assume that error is aborting the clone before it's complete, but I can't find any reference to the error or what it means in order to debug.
So the problem appears to be in the fact that Git-Svn tries to being cloning from one directory above the requested start point. Using the --no-minimize option fixed that.
git svn clone http://svn.domain.com/project working-dir -s --no-minimize-url