'git add.' does not work

I am currently trying to configure Git for a project that I have been working on for some time. I remember a long time ago when configuring Git, but I never used it for various reasons. Now I want to use it, I get a strange problem, which, it seems to me, is related to the old installation.

To start a new one, I installed a new Ubuntu OS so that there is no Git install present, and I copied the project (Grails). Then I went to the directory and executed the following commands:

git init git remote add origin https://USERNAME@bitbucket.org/USERNAME/APPNAME.git 

Then I ran:

 git add . 

Here I get the error below:

 fatal: Not a git repository: /home/user/workspace/App_V3/.git/modules/plugins/grails-spring-security-ui 

This error is strange because it does not even correspond to the directory I am in, since the directory is below:

/ home / user / Workspace / App_V7 /

I think that initially I could configure Git in the App_V3 folder on the old OS, but I don’t know why it still points to this directory, since I ran the code below to reinitialize it:

 rm -rf .git git init 

Can someone please help me with this as this is really frustrating: S

Thank you in advance

+4
git git-add repository
Jul 10 '13 at
source share
3 answers

I moved all the files one by one to a new folder, and then seemed to work fine :)

thanks for the help

+2
Jul 19 '13 at 13:04 on
source share

Moving repositories with submodules is problematic

I think that initially I could configure Git in the App_V3 folder on the old OS

This is the source of the problem.

The version of Git is important when the original repository (or, more specifically, the reference submodule) was originally created.

Consider a repository with one submodule in vendor/awesome , how Git behaved when creating a submodule, completely different.

git version <1.7.8

The contents of vendor/awesome/.git is a folder - just like any Git check, so for example, the folder structure at the checkout will be:

 .gitmodules .git ... vendor/ awesome .git config HEAD index packed-refs ... 

There is no problem moving this type of repository, as there are no paths that are stored anywhere.

git version 1.7.8 or 1.7.9

1.7.8 moved the location of the submodal .git folder

When filling in a new submodule directory with "git subodule init", the $ GIT_DIR meta-information directory for submodules is created inside $ GIT_DIR / modules // superproject directory and a link through the gitfile mechanism. This allows you to switch between commits in a superproject that has and does not have a submodule in the tree without re-cloning.

Therefore vendor/awesome/.git not a folder, it is a file with the following contents:

 gitdir: /absolute/path/to/main/repo/.git/modules/vendor/awesome 

And the general folder structure:

 .gitmodules .git ... modules vendor awesome config HEAD index packed-refs ... vendor/ awesome .git <- a file 

The contents of .git/modules/vendor/awesome/config indicates where the working tree is located:

 [core] ... worktree = /absolute/path/to/main/repo/vendor/awesome 

This was a rather surprising change - however, it introduced a problem, since absolute paths were used to refer to places.

git version> = 1.7.10

In version 1.7.10 , the use of absolute paths in submodules was changed

The entire directory that hosts the top-level superproject managed by the "Git Submodule" can be moved to another location.

Now vendor/awesome/.git , if this or a later version of Git is generated, will contain:

 gitdir: ../../.git/modules/vendor/awesome 

The contents of .git/modules/vendor/awesome/config indicates where the working tree is located:

 [core] ... worktree = ../../../../vendor/awesome 

Again, there is no problem moving such a repository as paths relative to the main repository.

Moving repositories

With the old or new version of Git, you're good.

If you are sorry to work in the repository created in 1.7.8 or 1.7.9 (which, apparently, from the evidence in the question) and move the repository - there are 2 solutions :

  • Clone again
  • Valid paths in .git submodule files and corresponding worktree configuration settings
+10
Jul 19 '13 at 13:40
source share

Instead

 git init git remote add origin https://USERNAME@bitbucket.org/USERNAME/APPNAME.git 

you should use

 git clone origin https://USERNAME@bitbucket.org/USERNAME/APPNAME.git . 

since you want to clone an existing repository and do not recreate it.

0
Jul 19 '13 at 13:08 on
source share



All Articles