2

Now I copied a folder into current repo, but I could not add the new folder into the repo. Then I tried using this command(git version 2.26.3):

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/retire% git add zuul-service 
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/retire% git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

seems did not add success, I tried using this command to force add to the repo:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/retire% git add --force zuul-service 
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/retire% git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

still not work. the next I tried to modify the folder zuul-service file, no file change tips when using git status to check. I also check the root folder's .gitignore and did not find ignore the zuul-service folder. This is my first time to encount this strange problem and I have no clue about this problem. Where is going wrong and what should I do to add the zuul-service folder into current repo? This is the project structure:

enter image description here

this is my .gitignore files content:

# Compiled class file
*.class

# Log file
*.log
log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
*.icloud
*.bin
*.lock

.idea

*.tmp

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# dolphin-music
dolphin-music/dolphin-music-api/build/
dolphin-music/dolphin-music-service/build/
dolphin-music/dolphin-music-service/testngOutput
dolphin-music/dolphin-music-service/out

# dolphin-post
dolphin-post/dolphin-post-api/build/
dolphin-post/dolphin-post-service/build/
dolphin-post/dolphin-post-service/testngOutput
dolphin-post/dolphin-post-service/out

dolphin-acientbay/dolphin-acientbay-api/build
dolphin-acientbay/dolphin-acientbay-service/build
dolphin-acientbay/dolphin-acientbay-service/testngOutput
dolphin-acientbay/dolphin-acientbay-service/out

dolphin-common/build/
dolphin-common-biz/build/

dolphin-manage/dolphin-manage-service/out

eureka-service/out/

.gradle

.DS_Store

.gradle/buildOutputCleanup/buildOutputCleanup.lock
.idea/workspace.xml

dolphin-manage/dolphin-manage-service/out

dolphin-template/dolphin-template-service/out

dolphin-acientbay/dolphin-acientbay-service/out

the first time, the folder zuul-service contains a .git dir. then I removed it using this command:git rm -rf .git. now the dir did not contains .git folder.

Dolphin
  • 29,069
  • 61
  • 260
  • 539

1 Answers1

1

the first time [I ran git add zuul-service], the folder zuul-service contain[ed] a .git dir.

That would do it. Git would add zuul-service as a gitlink, the operational half of a submodule. From this point on, the Git in which zuul-service was added is a superproject and zuul-service is a submodule within it.

then I removed it using this command: git rm -rf .git.

That would not work:

$ git status
On branch master
nothing to commit, working tree clean
$ git rm -rf .git
fatal: pathspec '.git' did not match any files

What would work is rm -rf .git, or rm -rf zuul-folder/.git if you are still in the superproject repository. I'll assume that this is what you did.

now the dir [does not contain a] .git folder.

That's good and necessary (assuming that this result is what you want), but there is one more step to take: in the superproject, we need to stop it from being a superproject holding a gitlink for zuul-service, using:

git rm -f zuul-service

If you had added it as a proper submodule (with git submodule add) rather than just as a gitlink, there would be more to do here; see How do I remove a submodule?

Once there's no longer a gitlink in the way, git add zuul-service should work as you expected it to work earlier.

torek
  • 448,244
  • 59
  • 642
  • 775