Uploading project on GITHUB not open the code files [duplicate] - github

I have recently pushed to github, and see a white arrow on one of my folders.
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?

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.

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

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.

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

In my case:
git rm --cached portal
ls
git status
git add --all
...

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

It's due to the .git file in some of your subfolders. If you cannot find it then follow these steps....
Click file option Click this image - 1
Go to Preferences , then click settings Click this image - 2
Look for text editor, then click files Scroll down to check .git in Exclude
section. Click this image - 3
If .git is present, then remove it.
Now you will find .git folder in your main or sub folder....delete it and upload the folder to GitHub.

THIS WORKED FOR ME !!
Go to your project folder.
Go to "View" from the nav bar, go to "Show" and check "Hidden Items".
Delete all the ".git" folders from your project.
Initialize new or existing repo again and push your code.

Related

How can I stop cloning my application files on GitHub?

I want to stop cloning my application files to Github, How can I do that completely and remove the circle status on each solution files?
Environment: Visual Studio for Mac
Are you intending to have git ignore those files completely?
You can use a gitignore file (.gitignore) in the root working directory of your project to specify which files to ignore. In there, specify a filename per line in that file, or a whole directory to be ignored (eg: Shared/*).
You'll also need to remove those files from your git repo, since they've already been committed.
Copy-pasting from here:
Unstage the file
git reset HEAD newfile
Remove the file from git
git rm --cached newfile
Deleting the file will count as a commit, so you'll need to git push once you're done.
Also note that the file(s) and their contents will still exist in the git commit history, so this isn't a good idea if the goal is removing files with sensitive info.

github desktop not showing folders

I made changes on the folder called "client/" but they are not shown in GitHub Desktop, thus I can push it to my repository:
Inside there is a .gitignore file, and I have tried deleting it but even so the "client/" folder did not appear.
Here is the content in gitignore file.
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
How can I see changes in client/?
First, you can check if any .gitignore rule applies to your change (therefore ignoring said change) with:
git check-ignore -v -- client/my/changed/file
If it does return anything, any modification to that file would be ignored.
Second, check if client is a nested Git repository (meaning, with a client/.git subfolder): that would also explain why a change in that nested repository is not shown when GitHub Desktop display the parent repository.
The OP Henry mentions in the comments:
git check-ignore -v client/node_modules`
fatal: Pathspec 'client/node_modules' is in submodule 'client' , so did other folders
That means it is a git submodule which is declared in the parent repository, in the .gitmodules.
The client folder, therefore, is supposed to be empty on the GitHub parent repository: it is a gitlink, a special entry in the index, referencing the tree SHA of that submodule repository.

Creating new git repository, can't add directory

I am about to throw my laptop through a wall, and am hoping for help before reaching that point. For reference, I am following these instructions exactly - https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/.
I have a directory ".../path/thisdir". Inside of thisdir are (1) a file called Demo.R and (2) a directory called sportVU. sportVU is a directory with ~15 files in it.
When I follow the instructions in that link, my github repo looks like this:
https://github.com/NicholasCanova/packageSportVU
Notice that the sportVU directory link cannot be clicked in github, and when I download the repo, sportVU is an empty folder. Why is this happening? This shouldn't be so tough.
EDIT: this is what the repo looks like in my local machine, I'm 100% sure it's not empty:
It could be that you have two .git folder in your directory. View hidden folders to see.
Similar questions:
What does a grey icon in remote GitHub mean
Why can I not open my folder in GitHub?
Since Git doesn't store empty folders the steps you should follow exactly are:
Delete the old repo and start again following exactly my steps.
git clone <repo url>
Inside the folder of the cloned repo create a directory manually and name it as you want i.e sportVU.
Drag and Drop all the files you want in the sportVU direcrory.
cd to Myrepo/sportVU and type git add *
type git commit -m "added some files"
git push -u origin master.
and you should be all set

Github Project is in subfolder instead of root

A Project which i uploaded in eclipse to github is in
(For example my project is called SuperHero)
/SuperHero/SuperHero
but i want it in the root of the Project
/SuperHero
It just seems you have an extra folder either created by Eclipse or you. The easiest way would be to do this on the command line. I'm going to assume you want to retain the first folder because that's the folder containing .git and the container of your git project. As such the steps below basically move all the contents from SuperHero/SuperHero to SuperHero. I'm not sure what Eclipse is doing here so I'm going to give you the instructions to remove the extra folder and update the changes in GitHub. At this point you might need to re-import the project in Eclipse.
On a terminal or gitbash navigate into the first SuperHero
cd ~/whateverpaththisis/SuperHero
Lets move all the files from the second SuperHero folder into the first:
mv /SuperHero/* .
Remove the empty SuperHero folder:
rm -R SuperHero
Check if all the changes make sense with:
git status
Commit the changes:
git commit -am "Removed extra folder created by eclipse"
Push the changes
git push origin <branchname>
If you now go to GitHub you should see the project laid out in the project's homepage without a containing SuperHero folder.
Hope this helps.

GitHub repository folder icon is black and not click-able

I am new to GitHub and finding it incredibly hard to learn. I am following the instructions here to create new repositories from an existing directory containing the project and typing git init ... etc.
However I created a repository in the wrong place and then deleted it by going into Settings at github.com. Then, when I tried to re-push the files the way I wanted it, one of the subfolders is now black (the one I had just deleted the repository for) and now not clickable - i.e. does not appear to be there. See statistics_project1 in screenshot below.
It's very hard to troubleshoot a problem like this. There is no error message or explanatory text when you hover over the black sub-folder.
This post seems similar but I don't know. The solution looks complicated.
Cannot remove submodule from Git repo
Could someone please tell me what a black 'unclickable' folder means in a github repository?
Cannot remove submodule from Git repo [duplicate] had give the answers and steps to do if you have git installed.
"Via the page Git Submodule Tutorial:
To remove a submodule you need to:
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
Commit git commit -m "Removed submodule "
Delete the now untracked submodule files :rm -rf path_to_submodule"
copy from remove a submodule
In fact the solution was a lot simpler. The 'blackened' folder is in fact the old repo that was not properly removed locally. As recommended by the author of the minimal tutorial I mentioned above, I simply removed the .git subdirectory which contains all git info and then re-pushed the repository to github.com and now everything is back to normal.