Submodule update fails with latest update - tortoisegit

Since I updated TortoiseGit to the latest version 2.7.0.0, the Submodule Update now fails and returns the following.
git.exe submodule update --progress --init --recursive --force --merge --remote -- "src/myproject"
usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] [--] <path>...
or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...]
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
git did not exit cleanly (exit code 1) (827 ms # 9/13/2018 11:05:54 AM)
I do not use the command line, I use the TortoiseGit contextual menu.
I can always go in Git Bash here and enter the following commands, but I want to know why doing it from contextual menu is broken.
git submodule update --init --remote -f --recursive Src

There is a difference on the cli command line: In TortoiseGit you have checked the merge option, on Git bash you haven't. This might cause an incompatibility if you have set checkout or rebase in the Git configuration.
Maybe this is related to: https://tortoisegit.org/issue/3218

Thanks to MrTux
Following the link you posted, I ended up on that comment:
Sven Strickroth #mrtux ยท 1 month ago
Owner
Have you checked that TortoiseGit uses the "right" version of Git? Maybe you have another older version installed which cannot handle the config value.
The answer was to update my GIT version who was 2.08 to the latest 2.19. To do that, I just downloaded the executable and it upgraded my GIT automatically.

Related

git error you need to resolve your current index first

% git checkout branch02_vr
M r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
M r2nr/r2nr.xcodeproj/xcuserdata/vhrao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
M r2nr/r2nr/Base.lproj/Main.storyboard
Switched to branch 'branch02_vr'
on my branch branch02_vr:
% git add *.*
% git commit -m "message"
% git push -u origin branch02_vr
% git status
On branch branch02_vr
Your branch is up to date with 'origin/branch02_vr'.
nothing to commit, working tree clean
Successful so far.
Then I wanted to merge my branch02_vr into main
% git checkout main
% git merge branch02_vr
Updating dd5bfe5..0284d6d
error: Your local changes to the following files would be overwritten by merge:
r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
Please commit your changes or stash them before you merge.
Aborting
% git commit -m "message"
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit (use "git add" and/or "git commit -a")
I dont understand the error here. So I just follow git prompts to fix the issue
% git add r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
% git merge branch02_vr
error: Your local changes to the following files would be overwritten by merge:
r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
% git stash
% git merge branch02_vr
Looks like this worked. I go to remote main and verify the code changes are merged from brnach02_vr into main
% git stash pop
warning: Cannot merge binary files: r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate (Updated upstream vs. Stashed changes)
Auto-merging r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
CONFLICT (content): Merge conflict in r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
Unmerged paths:
(use "git restore --staged ..." to unstage)
(use "git add ..." to mark resolution)
both modified: r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit (use "git add" and/or "git commit -a")
The stash entry is kept in case you need it again.
I dont understand what is going on with xcuserstate file
% git checkout branch02_vr
r2nr/r2nr.xcodeproj/project.xcworkspace/xcuserdata/vhrao.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
error: you need to resolve your current index first
I don't understand what is going on with the xcuserstate and the errors that are coming from it.
I am working in a team and do not want to mess up others files. I cannot checkout my branch02_vr again. Can someone explain and help?

How to include files from another repo in Jekyll build?

When I run this, files changes from the copied /first-repo are being ignored by bundle exec. How can I make sure that the files from /first-repo are included?
#!/bin/bash
cd /first-repo;
git pull;
cd /second-repo;
git pull;
# copy folder from first repo to second repo
cp -rf /first-repo /second-repo/destination_folder;
git add -A;
git commit -m "update destination folder from first repo";
git push;
# build
bundle exec rake build_site;
Sounds like you could use a Git Submodule.
Continuing the example, in second-repo you can instantiate a git submodule of first-repo to get the whole first-repo repository as a directory inside second-repo. You can also use the Jekyll config include variable to specify what files from first-repo to use in second-repo.

Binary file showing as modified after git checkout

For some reason, after cloning a repository and changing branch I had one jar file marked as modified (without being modified) and I can't seem to un-modify the file (which prevents merging branches.
PS D:\src\expm> git status
On branch epic-my-wallet
Your branch is up-to-date with 'origin/feature-01'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Test/Selenium/selenese-runner.jar
no changes added to commit (use "git add" and/or "git commit -a")
I tried to undo with the checkout command
PS D:\src\expm> git checkout -- .
git status output the same exact message as previously.
I tried to reset it from HEAD with
PS D:\src\expm> git checkout -f HEAD
Your branch is up-to-date with 'origin/feature-01'.
Please note that jar files are flagged as handled by LFS in the .gitattributes file
*.jar filter=lfs diff=lfs merge=lfs -text
Not quite sure on the next step here. The file has not been modified since its commit months ago.
edit
I should add that today we tried to reset the cache with git rm . -r --cached and removed the LFS cache as well (physically remove the .git/lfs folder) and re-download the files with git reset --hard.
Due to your git setting to handle end of line, which should be to 'autocrlf', git modify/corrupt the jar file at checkout!
You should add a '.gitattributes' file in your repository where you set the 'jar' files as 'binary' and git will no more try to convert end of lines.
That's the recommended way to handle end of line in a git repository to solve such problems...
It seem the problem was linked to Git LFS in some way. We upgraded both Git (from 2.8.4 to the current at 2.9.3) and Git LFS (from 1.2.1 locally to the latest 1.3.1 at the moment). Then deleted and re-added the jar file.
We did a clean clone on a new folder after that and the problem seemed to be resolved. Could be the upgrade of git + lfs that resolved the issue.

Can't switch branch: untracked working tree file because of case-insensitivity?

I want to merge the develop branch into the master branch and I thougt I do something like this:
git checkout master
git merge --no-ff develop
git tag -a 1.0.0
but on checkout I get
git checkout master
error: The following untracked working tree files would be overwritten by checkout:
Project/Resources/someimage.png
Please move or remove them before you can switch branches.
Aborting
But I have a file someImage.png in my develop branch and it seems that git has somehow an old file. Is GIT case-sensitive? On the local folder there is no such file.
Shoud I simply use git rm -f filename?
Edit:
Now I tried to delete the file, but I get
fatal: pathspec './Project/Resources/someimage.png' did not match any files
Now I'll try to checkout the master branch with -f.
I forced the checkout like this
git checkout master -f
and the local differences should be ignored. I think through deleting and re-inserting the image there was a problem in the index or so.

Is it possible to add a git submodule with recursive flag?

I am adding a submodule to my project which contains another git repo.
To get the module I ran:
git submodule add git://github.com/biakaveron/debug-toolbar.git modules/debug-toolbar
Then ran:
git submodule update --init --recursive
Which generated this error:
fatal: Not a git repository: ../../../../../../..//d/websites/project/.git/modules/modules/debug-toolbar/modules/vendor/firephp
Failed to recurse into submodule path 'modules/debug-toolbar'
I have run into similar problems before. Previously I just added the submodule and then re-cloned the project with the recursive flag (git clone --recursive project.git) which works. However it would be easier if I could get the submodule to pull in recursively in the first place. Is there a way to do this?
One possible cause could be the fact that github.com/cadorn/firephp-libs mentions:
THIS PROJECT HAS MOVED TO THE FOLLOWING REPOSITORIES:
https://github.com/firephp/firephp
https://github.com/firephp/firephp-core
So you might want to update the .gitmodules file of debug-toolbar first (after a git submodule update --init, without the --recursive part), and then, try again the git submodule update --init --recursive)
The OP did:
committing, then a recursive clone - which worked.
Original answer:
It seems that the path definition for one of the submodules (in the .gitmodules file) is not correct:
Being a relative path, it won't resolve successfully when cloned/updated by a git submodule --recursive command done from a parent repo for which said relative path is invalid.

Resources