126

I have recently pushed to github, and see a white arrow on one of my folders.

enter image description here

and when i click on the folder, it does not open it. On my local machine, it has contents, but in github i cannot access them. What does this mean?

Ank i zle
  • 2,089
  • 3
  • 14
  • 36

10 Answers10

114

Symptom

Check if locally you have a .git/ sub-folder under that folder.

Cause

That would mean the folder (locally) is a nested Git repository, whose tree SHA1 is recorded as a "gitlink" (gray folder with straight white arrow)

What you would then see on GitHub is that gitlink: SHA-1 of the object refers to a commit in another repository, represented by an empty folder name. It is a nested Git repository.

If you see a folder @ xxx, then it is a submodule entry, meaning your own repository has a .gitmodules in it, which records, in addition of the gitlink, the actual URL of the remote repository.
It represents the object name of the commit that the super-project expects the nested submodule's working directory to be at.

In both cases (white arrow with a folder name, or white arrow with folder @ xxx, folder name and version), it is a Gitlink represented a nested Git repository: a placeholder for another Git repository, hence an empty folder. But in the second case, that empty folder would be referenced/visible in a special .gitmodules file.


Solution (to remove the white arrow)

In order to restore that folder content:

submodule:

A git clone --recurse-submodules would restore the content of that submodule in your local repository (as opposed to a nested Git repo, where its URL is not recorded, and the content of the folder would remain empty)

The white arrow would remain on the remote repository, with folder @ version displaying what SHA1 of the submodule repository is referenced by your project.

Nested Git repository:

Alternatively, you could, if you don't care about the history of that folder, delete locally its .git subfolder (assuming it is not a submodule, meaning it is not referenced in a .gitmodules file in your main repository), add, commit and push.
The white arrow would then disappear, and you would be able to access that folder content on GitHub.

Then you would need to delete the gitlink entry:

git rm --cache client_folder 
# without a trailing slash: 
# not client_folder/ but client_folder

Finally, you can add, commit and push that folder content.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I'm facing this issue as well. used create-react-app inside node server folder to create client boiler plate. It has right arrow and adding recursively doesn't seem to do anything. – dee Jun 12 '20 at 15:05
  • @deechris27 "addling recursively"? do you mean "cloning recursively"? Does your main repo has a `.gitmodules`? – VonC Jun 12 '20 at 15:47
  • 2
    yeahh... there is no ".gitmodules" just the ".git" hidden folder. I deleted the ".git" that was inside the client folder and did a "git add ./client_folder" but still the right arrow is there. – dee Jun 12 '20 at 15:58
  • 50
    That is because you need frst to do `git rm --cached client_folder` (without a trailing slash: not `client_folder/` but `client_folder`). Then, and only then you can add, commit and push. – VonC Jun 12 '20 at 16:06
  • @deechris27 Well done! I mentioned it recently in https://stackoverflow.com/a/62255502/6309 – VonC Jun 12 '20 at 16:23
83

The arrow may mean that is a submodule.

You could try:

git add yourfolder

If that results in an error like:

xxx submodule xxx

appears, you may try this:

git rm --cached yourfolder

Then, you could successfully run:

git add yourfolder
Alexander Taylor
  • 16,574
  • 14
  • 62
  • 83
yunyi hu
  • 841
  • 4
  • 2
  • What is the purpose of `git rm --cached gitbook` ? – Sterling Nov 04 '20 at 05:09
  • 1
    @Sterling this command will delete gitbook from local repo , you do this , when you make minor changes ,for example delete a file , that is already cached on local repo , but "git" sees no different between your local repo and current directory, so you go and delete the cached folder from repo , then u add it again . – Rawand Deheliah Jan 17 '21 at 13:56
  • It worked! I had to replace `gitbook` with my folder name – Ajith Gopi May 18 '21 at 19:50
  • 1
    git add did not give me an error, yet git rm --cached followed by git add was still effective in fixing my problem. I think my submodule was in a half-removed state. – Alexander Taylor Jul 14 '21 at 23:47
11

On your machine, if you navigated to the directory with the arrow and tried to view hidden files, you'd see a .git folder, indicating that it is a repository. This means that it is a repo contained inside the outer repo that you had pushed to GitHub.

The easiest way to get rid of the arrow and start seeing your files properly (in my opinion) is by deleting the .git folder. That way, it ceases to become a git repo and is a regular folder once more.

Now when you push to GitHub, you can normally access the folder and view all its contents.

Christian
  • 4,902
  • 4
  • 24
  • 42
sanya29
  • 141
  • 4
  • 2
    Solved it and now understand it. Delete the git files in that folder, git rm --cached folder_name, git add folder_name. Thank you – Wesley Barnes Mar 17 '22 at 17:24
6

In my case:

git rm --cached portal

ls 

git status

git add --all

...

enter image description here

Consule
  • 1,059
  • 12
  • 12
5

If you want to remove a submodule from the git config files, Follow this, remember that if you DON'T want to delete the local directory of that submodule, DON'T do Step X:

Delete the relevant section from the .gitmodules file.

Stage the .gitmodules changes git add .gitmodules

Delete the relevant section from .git/config.

Run git rm --cached path_to_submodule (no trailing slash).

Run rm -rf .git/modules/path_to_submodule (no trailing slash).

Commit git commit -m "Removed submodule "

(Risky)Step X :- Delete the now untracked submodule files rm -rf path_to_submodule

Taha Ali
  • 457
  • 1
  • 5
  • 7
4

it worked, I followed these steps

  1. remove it by git rm --cached folder-name
  2. git add folder-name

that is it.

  • This has already been suggested by several existing answers ([example](https://stackoverflow.com/a/63068443/3025856)), but with less explanation and context. Before answering questions on Stack Overflow, be certain to read the existing answers to ensure your suggestion hasn't already been proposed. If it has, please don't repeat the answer. – Jeremy Caney May 26 '23 at 03:01
3

for me, the history of changes in the subfolders were no longer important

start by removing .git from the subfolder

git rm --cached myfolder

git add myfolder

git commit -m "making myfolder available"

git push
fulo
  • 95
  • 1
  • 7
3

It's due to the .git file in some of your subfolders. If you cannot find it then follow these steps....

  1. Click file option Click this image - 1

  2. Go to Preferences , then click settings Click this image - 2

  3. Look for text editor, then click files Scroll down to check .git in Exclude

section. Click this image - 3

  1. If .git is present, then remove it.

  2. Now you will find .git folder in your main or sub folder....delete it and upload the folder to GitHub.

VaithiJ
  • 31
  • 2
0

THIS WORKED FOR ME !!

  1. Go to your project folder.
  2. Go to "View" from the nav bar, go to "Show" and check "Hidden Items".
  3. Delete all the ".git" folders from your project.
  4. Initialize new or existing repo again and push your code.
0

1 Firstly do "Remove-Item -Recurse -Force .\.git" command in PowerShell (without quotation) in the folder which is showing arrow. It will recursively delete the .git folder which contains all git related files and folder.

  1. git init.
  2. git add .
  3. git commit -m "making folder available"
  4. git push