did the git submodule behavior change? - git-submodules

I am using a new red hat os, with git version 1.7.6 (also tried 1.9.2). I also have a debian 6 machine with git 1.7.6. When I create a clone and populate a submodule on the debian machine, the submodule ends up with a .git directory. However, when I perform the same commands on the red hat machine, my submodule ends up with a file named .git, and a new directory under my root repo in .git, named modules. This modules directory appears to contain the contents I would expect to be in .git under the submodule. What is going on???

Yes, it did change in git 1.7.8, to make checking out commits across the introduction of submodules easier.
See https://raw.github.com/gitster/git/master/Documentation/RelNotes/1.7.8.txt near the end of the Updates, above the fixes.

Related

Docksal and Git shallow issue

When I set up a docksal project, it uses git and the project folder ends up with a remote:
https://github.com/docksal/boilerplate-drupal9-composer.git
I then add another remote, to the repo for the codebase I am developing.
The problem is that the clone done by docksal was shallow, and when I try to push to my repo the push is rejected because of the shallow setting (the shallow file in .git)
Feel free to drop the .git folder and initialize a fresh git repo in the project folder Docksal created.
In case you'd prefer to inherit the boilerplate git repo commit history, you can always clone the repo directly:
git clone https://github.com/docksal/boilerplate-drupal9-composer.git drupal9
cd drupal9
fin project start

Incorrect path for Pods-testAppTests/Pods-testAppTests.debug.xcconfig: unable to open file

So I recently uploaded my react-native project on GitHub, then cloned it back to see how it will build(did it for first time... yeah). And on react-native run-ios I got a repetitive error: "react-native-app/ios/Pods/Target Support Files/Pods-testAppTests/Pods-testAppTests.debug.xcconfig: unable to open file (in target "testAppTests" in project "testApp") (in target 'testAppTests' from project 'testApp')
I found a solution, where this:
cd ios
pod deintegrate
pod install
helped me as the project then built and ran correctly.
So my question is, how to upload it to GitHub in a way so it builds always correctly after cloning it?
Update
Checking and editing .gitignore solved this problem.
Maybe this is linked to files which have been added/committed, while they should have been ignored, private and local only (not uploaded to GitHub)
Check your .gitignore: here is one for ReactNative, as explained in "Creating a .gitignore for a Clean React Repository", blog post written by Parker Johansen.
Then, assuming you don't have any pending changes/work in progress, you can, as explained here, apply your new .gitignore to your existing repository:
cd /path/to/local/cloned/repo
# create your .gitignore
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
git push
Finally, clone it again, and see if it compiles better.
The OP adds in the comments:
I found that folder 'Pods' doesn't exist on GitHub, that's why this error occurs, how can I add it to my /ios folder on Github correctly
I advise to check if there is a .gitignore rule which would ignore said folder:
git check-ignore -v Pods/aFile_inside_Pods

Git directly commit file to git and/or gitlab

So, here's my use case:
I'm attempting to develop an internal Mac app for the non-developers on my team, to edit some of my game's parameters. Ideally, the application will be able to recreate the necessary config files and directly commit/push them to my gitlab instance, which would trigger a CI build.
I know I could programmatically clone my repo to their machine and then edit it programmatically and commit the changes, but I'm trying to avoid having to have each user who is only editing a few files cloning 2+GB of code.
Any suggestions how to commit directly to a remote repo? In this case, both the user and my server can be considered "trusted". Thanks!
That would look like those config file could be in their own (very small) git repository, and kept in the main repo as a submodule.
However, once a submodule has been pushed back, a hook should make sure the parent repo update its submodule reference (git submodule update), and add+commit the new SHA1 of said submodule which was just pushed.
Otherwise, the parent repo wouldn't realize that its submodule has changed.
That also means the parent repo should declare that submodule as following the latest SHA1 of master branch:
git submodule add -b master /url/to/submodule
For something as restricted as this a single-repo solution would also work:
Make a configs-only branch:
git checkout --orphan configs
rm all but configs
git add -A
git commit -mconfigs
git checkout main
git push server configs
In the config-editor repos:
git init configrepo
git remote add server u://r/l
git fetch server configs
git checkout -t server/configs
# work work, then
git commit -am "new configs"
git push
As part of your build,
git pull -Xtheirs configs

Adding files to .gitignore doesn't remove them from "untracked files"?

I recently started using git-svn, and tried to tell Git to ignore any files that the Subversion repo ignores (mostly binaries and object files), by running "git svn show-ignore >> .gitignore"
Then I ran git status, and saw that many of those files that are now on my .gitignore list, are still showing up under "untracked files". Why? What do I need to do to fix this?
Or am I going about this the wrong way? I just want to be able to run "git add ." without it adding in all that junk to the commit.
Thanks.
If you already imported those files in the Git repo, they won't be ignored until you git rm --cached them.
You need to remove those file from the Git index (hence the --cached option), before seeing the .gitignore working.

How to import local git repository into svn?

I am working on local git repository and I need to push my local git into existing svn repository. My git repository is pure local git repository, it was not init using git svn clone.
How can I import this local git repo into svn?
Preferably I'ld like to keep the git history being imported into SVN.
Currently the SVN repository is structure as:
https://svnrepohost
/branches
/tags
/trunk
/projectA
/projectB
/newProject
What I need it is to import my git repository into the https://svnrepohost/trunk/newProject above, assuming the newProject folder is empty.
I have finally solved this problem by the following steps:
Setup appropriate project folder in svn to be imported to, for example http://svnrepo/svn/trunk/newProject
Create a new git-svn repository
git svn clone http://svnrepo/svn/trunk/newProject
Add the git repo that we want to import as remote to the new git-svn repo
git remote add origin ../original-git-repo
Pull all the data from original-git-repo
git pull origin master --allow-unrelated-histories
Rebase local repository against svn
git svn rebase
Commit the changes into svn
git svn dcommit
Clean up the remote
git remote delete origin
The easiest way to do this is to just svn import the Git directory. That will lose you your Git commit history, however.
First of all, make sure the .git directory won't be imported by setting the global-ignores in the Subversion config file. Open your ~/.subversion/config file (that'll be in something like C:\Users\username\.subversion\config on Windows), find the section starting [miscellany], and add a line directly underneath reading as below:
global-ignores = .git
(if you already have a line with global-ignores = that doesn't have a # in front of it, then just add .git to the end of that line.)
Next, run the below:
svn import <path-to-local-git-repository> https://svnrepohost/trunk/newProject
That should copy the contents of the local Git repository onto the server exactly where you want it.
You may use SubGit.
$ svnadmin create repo.svn
$ subgit configure repo.svn
...
CONFIGURATION SUCCESSFUL
Adjust '/tmp/repo.svn/conf/subgit.conf' file
and then run
subgit install "repo.svn"
to complete SubGit installation.
$ nano repo.svn/conf/subgit.conf #edit to set git.default.repository=path/to/your/bare/git/repository
$ subgit install repo.svn
I would also recommend you to create a bare clone of your Git repository and to specify path to it (in git.default.repository) instead of your original repository. I.e.
$ git clone --bare path/to/your/original/repository path/to/your/bare/git/repository
After "subgit install" command the repositories (repo.svn and repo.git) will be in continuos synchronization (triggered by pre-receive hook in Git [that starts on pushing to your bare repository] and pre-commit in SVN). To stop synchronization you may run
$ subgit uninstall repo.svn
git svn clone http://svnrepo/svn/trunk/newProject
git remote add origin ../original-git-repo
git fetch origin
git checkout -b lmaster remotes/origin/master
git rebase master
git svn rebase
git svn dcommit