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

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.

Related

updating named git submodules fails with fatal error

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?

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

ignore all changes to dir

We have a git submodule, it's in a folder called 'config' in several repos.
I am getting this when doing a merge:
On branch oleg/feature/1537299444
Your branch is up to date with 'origin/oleg/feature/1537299444'.
Changes not staged for commit:
modified: config (modified content)
no changes added to commit
and it exits with 1.
How can I ignore all changes to the 'config' folder, which is a gitsubmodule?
I tried:
git checkout config
but that didn't do anything
Try first to check what kind of of diff/new element you see in the submodule.
cd config
git status
git diff
If you can, do a git reset --hard in that config folder (if you don't need any local modification done in config)
Then go back to the parent repo, and retry your git merge.

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.

Can I take a bazaar branch and make it my main shared repository?

I have a bazaar repository on a shared server. I'd like to clean up the repo and set it up from scratch but maintain my history. I don't know how the repository was created initially (is there a way to find out?).
Can I take a branch and make that into my main shared repo?
Is this a viable process:
bzr init-repo --no-trees /home/bzr/myrepository
cd /home/bzr/myrepository
bzr init stable
cp /home/oldbzr/branch_taken_from_current_repo/* ./stable/
cp /home/oldbzr/branch_taken_from_current_repo/.bzr ./stable/
Thanks
A "branch" and a "repo" in Bazaar are totally separate concepts. You don't convert a branch into a repo. What you usually think of as a repo (in SVN or Git, for example) is actually a branch in Bazaar. What you want to do is create a new repo, then copy the old branch into the new repo.
You almost have it right, but you don't want to use "cp", you want to use "bzr branch". Note: You can usually use "cp" to copy branches except when you want Bazaar to move a branch into, out of, or across a repository -- then you need "bzr branch" to intelligently repack the history. So here is what you want to do:
bzr init-repo --no-trees /home/bzr/myrepository
cd /home/bzr/myrepository
bzr branch /home/oldbzr/branch_taken_from_current_repo stable
Note that I am not doing "bzr init" -- I don't want to create a new branch, just copy the old one. And I am not manually copying the old branch or its .bzr directory. If you copy the old branch's .bzr, it will not end up using the new repository. By doing a "bzr branch" it will go "oh hey, I am moving into a repository. Therefore, I will put all of my commit data into the shared repository, and just put a lightweight branch in 'stable'."
You can use just plain branch into your shared repo as mgiuca suggested, but you also can convert your standalone branch to use shared repository. For that your steps should be extended with bzr reconfigure call:
bzr init-repo --no-trees /home/bzr/myrepository
cd /home/bzr/myrepository
bzr init stable
cp /home/oldbzr/branch_taken_from_current_repo/* ./stable/
cp /home/oldbzr/branch_taken_from_current_repo/.bzr ./stable/
cd stable
bzr reconfigure --use-shared
So, if we omit cp then you can create a shared repository "around" your branch:
cd /path/to/my/branch
bzr info # you should see you branch is standalone,
# i.e. not using shared repo
bzr init-repo ../ # create shared repo in parent directory
bzr reconfigure --use-shared # convert standalone branch to repository branch
bzr info # now you should see your branch is using shared repo