3

I own a Gitlab account. In a running repository I have cloned projects from github but on git add . they won't be tracked. How do I add cloned projects to my Gitlab account?

git branch -vva

* master                c9ef011 [origin/master] te
  remotes/origin/master c9ef011 te
Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59
fefe
  • 8,755
  • 27
  • 104
  • 180
  • Won't be tracked? Are you referring to remote tracking branches? Are you trying to push? From where to where? Or are you trying to import an existing project into Gitlab? – Ed I Oct 25 '14 at 21:57
  • so I have been cloning locally inside my project gits and I want push to the owned gitlab, but the cloned directories they won't be pushed to gitlab server – fefe Oct 25 '14 at 22:02

2 Answers2

3

A convenient option if you have many repos is to mass import:

  • go to the directory of a namespace (user or group), e.g. /home/git/repositories/username
  • get the bare repo: git clone --bare http://github.com/me/project. The created repo will end in .git and this is required.
  • run bundle exec rake gitlab:import:repos RAILS_ENV=production. The GitLab projects will get automatically created on the datbase for you under the user username.
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
1

Once you initialize a project in GitLab, you'll see a page like this:

enter image description here

The important part is adding the remote:

git remote add gitlab git@mygitlaburl:namespace/myproject.git

You'll need to add your public key by clicking on Profile Settings > SSH Keys > Add SSH Key.

Here are complete instructions: How To Use the GitLab User Interface To Manage Projects

UPDATE:

Your problem is explained here: Git repository within Git repository, which links to here: Nested GIT repo gotchas!

Community
  • 1
  • 1
Ed I
  • 7,008
  • 3
  • 41
  • 50
  • I already have this part. The Project is up and the branch is present in my GitLab. Now In my project I check out gits from github and those I try to push in my gitlab repository. But they won't be added. – fefe Oct 25 '14 at 22:25
  • Why don't you update your question with the output of `git branch -vva`? – Ed I Oct 25 '14 at 22:28
  • From that output, if you do `git remote -v` you'll see that origin probably refers to your GitHub remote. You need to do `git remote add gitlab git@mygitlaburl:namespace/myproject.git`. Then you can do `git push gitlab master`. – Ed I Oct 25 '14 at 22:36
  • no that one is okay. Probably I do not explain good the problem. So I can push to gitlab changes but what is not getting pushed are the cloned folders from Github. as example I have project A. Project A has couple of folders what I made myself. Than I clone a project from Github inside Project A let's name it cool_php. Than I want to add to project A and push it to Gitlab. – fefe Oct 25 '14 at 22:42
  • That is caused by the way in which git handles nested git repositories. You may need to learn about git sub-modules or use a build tool to manage external dependencies. See the answer update. – Ed I Oct 25 '14 at 22:49