StirlingCodingClub / studyGroup

Gather together a group to skill-share, co-work, and create community
http://StirlingCodingClub.github.io/studyGroup/
Other
2 stars 1 forks source link

Sub-modules in Gitkraken....? #29

Closed mattnuttall00 closed 4 years ago

mattnuttall00 commented 4 years ago

Hi all,

Quite a simple question (I think). I use GitKraken for my version control, which also allows me to switch fairly seamlessly between university and home computers.

I currently have one GitHub repo per thesis chapter. Yesterday I was sent an R project by one of my project partners. This project forms part of the chapter I am currently working on, and so I copied the project folder into my chapter repo. When I went to GitKraken to commit these files, I noticed that GitKraken had created a "sub-module" within my repo. I guess this is because GitKraken has recognised the folder as a separate mini-project within the wider project. I can see that it has appeared on the left hand side in GitKraken under "submodules".

This is all fine, and makes sense. GitKraken is recognising changes I make to files within the new "submodule", and I can commit these as normal.

However, in the "unstaged files" box of GitKraken, there is the new project folder, which sits there with the orange box (suggesting changes have been made). It won't allow me to stage or commit this folder. So all of the individual files can be staged and committed, but the folder cannot.

I suppose my questions are: Is this normal? Why can't I stage and commit this folder?

Thanks!!

bradduthie commented 4 years ago

Hi @mattnuttall00 -- quick question that I think might make it easier to answer yours: is the R project that one of your project partners sent itself a git repo? Or did you just get a folder with a lot of files inside of it?

mattnuttall00 commented 4 years ago

Hi @bradduthie , good question. I think it is itself a repo, as it has a .git and .gitignore file. Does having those files make it a repo?

bradduthie commented 4 years ago

Yep @mattnuttall00 -- that makes sense. Okay, so you're working with submodules in GitKraken. There is a video and post about this in the GitKraken support, but it might be more than what you really need. Give it a shot if you want to be able to manage both the subrepository and the outer repository (e.g., have a separate GitHub repo for both, with changes in the inner repo being incorporated into the outer one and pushed and pulled separately).

If you're just wanting to do stuff in the inner and outer git repository, but really have the outer repository as the one that keeps track of everything, then you don't even really need to pay attention to the submodules, I don't think.

To answer your question, all that you need to do is make sure that commits are made to any changes to the inner git repo before you make them to the outer git repo. If you open the inner one on GitKraken, stage and commit changes, then move back to the outer one, you should be able to commit them.

I've added a new repository where I tried this out for myself, as I have never done it before. Interestingly, the inner_git folder appears to be completely off limits. I think if I wanted to have one, then I would need to also make a separate repository on GitHub for it and link the two (as you have with the submodules in GitKraken).

bradduthie commented 4 years ago

So I got curious, and it does look like moving one git directory into another (as opposed to creating a new git submodule into an existing one) can create some issues (here's the inner git repository). These can be resolved fairly easily, but I'm not sure if GitKraken can do it.

Another option @mattnuttall00 is to move the inner git repository to somewhere else on your computer. Then, copy it, and paste it again into the outer repository, but then go into the inner repository and delete any hidden file or folder that starts with .git -- this will delete the whole history of the inner repository though, so you won't have it nicely merged with the outer repo.

All useful to know now!

mattnuttall00 commented 4 years ago

Hi @bradduthie, thanks a million for all that info! I'm not exactly sure whether I want or need that folder to remain as a separate submodule, with it's own commit history. I probably just want it as a regular folder within the existing repo, and so the option of moving the repo to a different place and then copying it back in and deleting the .git files is probably what I want to do. I'll have a think!

Happy Friday!