Creating new git repository, can't add directory - github

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

Related

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

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.

Switching Remote Urls from HTTPS to SSH

I tried to switch from a HTTPS to SSH repo using git. Below are the first commands I used.
Then, when I tried to add a branch to the staging area, I got the following messages:
I am not able to push anything or add any commits to git from my command line either. I get an error saying "could not read remote repository". Could someone please help me? What should I do now? I am new to git and I don't want to dig myself in a deeper hole!
Check for a .git/ subfolder in:
your current working directory (where you switch to SSH)
your parent folders
If you see one in any parent folder, that would make your current working directory a nested Git repository.
Ideally, there should not be any parent Git repository above your own: see if you can remove those parent .git folders (or move them elsewhere).

Can moving folders/files in github cause a problem?

My github repository is: https://github.com/zorlakov/moviesAndShows
In order to get to the react files and folders (src, public etc) you first have to open the movies-and-shows folder. I was thinking to copy all the content from that folder into the parent folder, and then delete that folder and push to github. Could this create a problem?
This should not be a problem for Github, or even Git.
However, if you want to keep history and ensure that Git is able to detect move/renames, you should work by steps:
git mv moves-and-shows/public .
git mv moves-and-shows/src .
git commit -m 'move public and src to root'
For the other files, it should also work.
I do expect that you will also have to fix hard coded path (replace moves-and-shows/public by public and so on).

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.

Add new folder with files to github

Probably one simple question. I pushed my first project to github. I've done it with Eclipse with EGit plugin. I've clicked on a project, chose to push remote and uploaded it to git. There I have created readme file online so the structure looks like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
I have one other folder with screenshots of the app which I would like to have outside my app folder. Something like this:
Git
-- AppFolder
------srcFolder
------libsFolder
------resFolder
------etc etc
-- Readme.md
-- ScreenshotsFolder
------screenshot1
------screenshot2
------etc etc
How can I accomplish that? I don't want to put that folder with screenshots to AppFolder. Thank you.
Locally, just create the ScreenshotsFolder in the same directory level as AppsFolder and README.md.
Then, git add ScreenshotsFolder will add the folder and all of its content (really, all content that is not in your .gitignore file if you have one).
Next just git commit then git push remote_repo remote_branch (ex: git push origin master).
If you aren't doing this via the command line, I'm sure the EGit plugin has some option to add the ScreenshotsFolder and do a commit then push...haven't used EGit myself, though. The steps are the same either way, just a different interface.
Are the files intended to be committed? If not, you could just .gitignore that directory.
edit: if the files are meant to be committed, why can't you just add and commit them like normal, but in new directory?