How do I add a local directory into github repository

743 views Asked by At

I am trying to add a whole directory into github. Below are the codes I am using to do that. the commit and push doesn't show anything new because I repeated the process to paste here; but those are commands I followed.

code

It adds the directory but I can not access the files inside. It looks like below.

github

Is there any easier way to add the sub directory? Is there any easier way to move repositories inside github?

1

There are 1 answers

0
Guildencrantz On BEST ANSWER

The folder image next to the Machine-Learning-Tutorials line in github suggests that you're adding a sub-module to an existing repository. That seems to be supported by the fact that you do a git init, but don't add a remote.

I'm guessing that ~/Documents/Merge/Git/Github/ is a git repository tracking github? If that's the case you don't need to do the git init--you already have a repository--and right now you'll actually want to remove the ~/Documents/Merge/Git/Github/Tutorials/.git directory. At that point if you do a git add Tutorials it should add the actual files and let you push them up to github.

If you have a repository and you just want to add more files (in the current directory or a subdirectory) you just need to use git add, there's no need to git init a directory unless you want to track it as a separate repository (known as a submodule).