Using git submodules as junctions in Windows - windows

If a submodule's directory is a junction (Windows), git doesn't detect it as a repository and cannot work on such submodule.
For example, imagine a repository root is in c:\src\root, and that has one submodule subrepo, that is a junction to another drive. So c:\src\root\subrepo links to d:\submodules\subrepo.
If you try any git command on c:\src\root\subrepo you will receive an error message like
$ git pull
fatal: not a git repository: d:/submodules/subrepo/../.git/modules/subrepo
How can I solve these issues?

As you see, the problem is that git resolves the junction and works on the destination directory, instead of using the original path.
To solve the junction problem with git and submodules, it is enough to make a second junction, but in reverse way, to the .git directory of the parent rep. This should be a sibling of the subrepo directory, so it can be found when constructing the ../.git/ relative path.
d:\submodules\.git ==> c:\src\root\.git
c:\src\root\subrepo ==> d:\submodules\subrepo
Note that this may be a mess if you have different set of submodules, so in this case just group them into the same directory to avoid conflicts with duplicated .git directories.

Related

versioning different directory name from repository

I have a local directory at my/local/directory/ with the files I wish to commit to the repository named differently than 'directory'. Is it possible to do this and if so how in the command line (windows)?
Perhaps you should read the Git manual first. You can name your directory as you like. The important think is the .git folder insight your directory.
If you have no git repository then you should initialize a new one and copy your files to that directory.
http://git-scm.com/book/en/v1

Make a folder both a symlink and a git submodule

This my project structure in a nutshell:
+ A
| + some content
|
+ B
+ A
I want in my main git repo a submodule in B that points to A. But since the A project contains the main method, I want to be able to quickly test before committing, so I'd like a symlink (or rather a mklink since I'm on windows) that points to A so it gets updated without committing.
The problem is that A doesn't have just "some content".
It also has a .git subfolder in it, which a submodule does not.
If you can, use git worktree in order to checkout a branch in a separate folder (than the original A cloned folder)
Then you can try and use a symlink from B subfolder to A, after adding A as a submodule in B.
Note: since Windows 10 build 14972 (Dec. 2016), symlinks (mklink) can be created without needing to elevate the console as administrator.
A better approach is described in "Git: Possible to use same submodule working copy by multiple projects?".

Why are these files not ignored by git?

My .gitignore file contains these lines :
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
But the following file is still tracked
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
Why is it so? How can I fix that?
PS: If I had MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger, the files are ignored. But I don't understand why it does not ignore them without this "hack".
EDIT 1
Contrary to what is said in one of the answer, the pattern
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
works !!! I mean, the files under /xcschemes are tracked.
See also the post Git ignore file for Xcode projects, where I get this .gitignore file.
EDIT 2
My Git version is 1.8.3.4 (Apple Git-47).
EDIT 3
When I git check-ignore this file, here is what I get
fatal: Not a git repository (or any of the parent directories): .git
But the fact is that a parent directory is a git directory...
EDIT 4
When I git check-ignore --no-index -- this file, here is what I get
[MT] PluginLoading: Required plug-in compatibility UUID 37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeSnippetsHelper.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2014-02-10 10:03:50.856 xcodebuild[1496:d07] XcodeColors: load (v10.1)
2014-02-10 10:03:50.859 xcodebuild[1496:d07] XcodeColors: pluginDidLoad:
fatal: Not a git repository (or any of the parent directories): .git
EDIT 4bis
From the root folder :
if I don't use the no-index option, there is no reply to git check-ignore.
if I use the no-index option: I get the error error: unknown option 'no-index'...
Strange ;-!
First, you can do a git check-ignore (git 1.8.3.3+) to see what rule is ignoring your file (assuming it wasn't in the index in the first place)
Second, read ".gitignore exclude folder but include specific subfolder":
It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+, see below)
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
So the file of xcschemes wouldn't be un-ignored anyway.
You needed to ignore parent folder per parent folder.
But a better approach is to ignores files only, and then exclude the folder:
xcuserdata/**
!xcuserdata/**/
!xcuserdata/**/xcschemes/**
Remember:
You need to exclude folders from the gitignore rules before being able to exclude files.
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:
commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However:
The directory part in the re-include rules must be literal (i.e. no wildcards)
So that wouldn't have worked here anyway.
Adding file names to .gitignore helps prevent you from adding the files unintentionally.
If you do something like git add . to add a folder full of files to the repository, the files (or filetypes) ignored in .gitignore will not be added.
They would have to be added by using the -f flag with the git add command.
It will not change anything if the files are already tracked.
You can stop tracking the files by using the answer to the question:
Remove a file from a Git repository without deleting it from the local filesystem
edit: After rereading the question a few more times, I think you may be having roughly the same issue that was addressed in this answer:
.gitignore - ignore any 'bin' directory

How to recover files in git repository

I had a project connected to a local git repository. I decided to reinit that after some mess with branches and commits. Firstly, I deleted old repository with "rm -r .git", and than created new one with "git init". After that, I found out my work directory looking the same way as if my project was only created - the results of all my work are gone.
Trying many recipes from the internet didn't give results. Please, give me a cue, is there any chance to recover my project's files or not.
In the case your "local repository" means you did git clone /path/to/your/local/repo, yes you can restore it by cloning again with git ckibe /path/to/your/local/repo, or git remote add origin /path/to/your/local/repo && git fetch && git pull origin/master ).
Same thing if you cloned from a remote repository.
Otherwise, there is no way to recover your files with git, except if you removed by a graphical interface (which move to a trash folder instead of making a real deletion) or if you have a back up.

How to point gitbox/git to different local directory

Hi guys I have a remote repository cloned locally, Because my new changes have saved it to a different directory (workspaces in eclipse) I want to point git to the workspace directory rather than the other directory, how do I do this? Gitbox doesn't seem to have any options, and I can't see the .git folder
In your WORKSPACE do
git init
and then from where you pulled your copy initially. Do
git pull /path/to/your/workspace/project/dir

Resources