Make a folder both a symlink and a git submodule - windows

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?".

Related

Converting a submodule to a folder within a GitHub repo

I'm new to using GitHub and I read up a few of the solutions on stack overflow but I couldn't understand them.
I pushed a folder in one of my repository and it shows up as a gray submodule. I need it to be a regular directory inside my repo. Can someone simplify what I need to do or show steps because I don't know how to deal with submodules or .gitmodules or where to find them
Thanks in advance!
If you don't see a .gitmodule at the root of your main repository, that means your subfolder is a nested git repo, recorded as a gitlink (a SHA1 reference), which is what you see as a grayed folder.
All you need to do is:
delete the .git subfolder you should find in that folder
go back to the main repo (one folder up)
add, commit and push: that should push the folder content instead of a tree SHA1 reference.

Does Xcode take care of multiple .git in sub-folders nicely?

For a new project Foobar in the ~/Code folder, Xcode creates the following in ~/Code/Foobar/:
.git
Foobar
Foobar.xcodeproj
For third party libraries, I put them in a ~/Code/Foobar/Vendor folder, for example:
cd ~/Code/Foobar/Vendor
git clone https://github.com/ohho/GPUImage.git
There two .git folders:
~/Code/Foobar/.git/
~/Code/Foobar/Vendor/GPUImage/.git/
In the future, will Xcode's Source Control > Commit Selected Files... feature work nicely with both .git repositories?
XCode 4 does know how to manage submodules, if you chose that approach (see "Xcode 4 workspace with two interdependent projects: should I also use git submodule?").
Such an approach is illustrated in "adding a simple library to an xcode 4 project".
But even without submodule, it should manage nested git repos just fine. The parent git repo would ignore the nested one.

Changed folder structure in Xcode Project not reflected in Git Repository

I have an Xcode project that is under version control. I've grouped the classes in the project navigator into folders based on what the classes do (eg. Models, Views, Controllers, etc.). However, these folder structures seem local to my machine and it is not reflected in my own local git repository, or if I do a git pull from another machine, the folders that I've created or organized my classes into don't appear. So, How do you get the changes you make (organizing the classes into folders) to reflect in your local and remote repository?
Try this
# modified, new and deleted files
git add -A
ref
I found that the adding a folder or directory manually inside the local repository to work for me. Create the folder in the repository,git add folder_name/ to actually track and add it to the repo. The files then can be moved into this folder. Depending on how you move it, you may need to do git rm <file_name> and git add </folder_name/file_name>.

How can I track a git repository in a different directory?

So I have a project that is a git repo which contains another git repository. So the structure is this:
/gitProject
/other
/stuff
/anotherGitProject
Currently, I've got anotherGitProject set up as a submodule of gitProject. My problem is that I have to deploy anotherGitProject to another part of my hard drive. Since anotherGitProject functions as an add-on, I just copy the contents of anotherGitProject directly into the other project's directory tree:
/gitProject
/other
/stuff
/anotherGitProject
/otherProject
/(contents of anotherGitProject+otherProject)
My question is: How can I keep track of the changes I make to anotherGitProject within gitProject? This seems really convoluted, but I need to make changes to anotherGitProject on top of otherProject or else this wouldn't be an issue.
The idea would be to:
clone anotherGitProject in otherProject,
or even as otherProject (if the content of anotherGitProject needs to be directly within otherProject, in which case:
rename otherProject in otherProject.tmp
clone anotherGitProject as otherProject
copy the rest of otherProject.tmp content in otherProject
add a .gitignore to ignore anything which isn't anotherGitProject original content
add to anotherGitProject initial repo (the one being a submodule to gitProject) a remote pointing to otherProject
That way, you can fetch/pull from otherProjectdirectly back in anotherGitProject
If anotherGitProject is, as a plugin, a simple subdirectory of otherProject, the process is much simpler, since, as I mention in my first point, you can simply clone anotherGitProject directly in the destination (within otherProject).
The remote step is the same:
cd /gitProject/anotherGitProject
git add remote anotherGitProjectDeployed /path/to/otherProject/anotherGitProject

Create git repository after project creation

I know there's an option to make a local repository for your project when you first create it, but is there an option create a repository after you've created your project?
Sure, just run the following command in your project directory:
git init
This will create the .git directory containing an empty repository. Then, add and commit your files.
In the command prompt, make sure you're in the desired directory and perform a git init and you will have created an empty repository.
You can then proceed to add the files and directories to the repository by doing
git add <filename1> <filename2> ...
or you can select whole directories and use * to act as a wild card of sorts.
git add ./*
If you have any more questions check out these pages:
http://gitref.org/creating/
http://gitref.org/basic/#add
Hope this helps.
You should go to your Xcode menu, click Source Control > Create Working Copy...
Xcode will automatically create your .git folder repository.
Good luck, and make sure you have a backup of your project before trying something else.

Resources