2

I have the following projects in a folder structure.

  • Homework

    • Ex1
      • main.cpp
      • class1.cpp
      • readme.txt
    • Ex2

      • main.cpp
      • class2.cpp
      • readme.txt
    • Ex3

      • main.cpp
      • class3.cpp
      • readme.txt
    • readme.txt

I want to submit this whole 'project' to a given repository(which I've already set up). So I first did cd to the Homework directory and did

$git init

Then I did

$git add --all

After that I commited by

$git commit -m "Adding all folders"

Then did the push as

$git push origin master

After this when I opened the repository URL on browser I see only the readme.txt in Homework directory. I don't see the Ex1,Ex2,Ex3 folders and their contents.

What am I doing wrong here?

Pasan W.
  • 674
  • 2
  • 10
  • 23

2 Answers2

3

If Ex1, Ex2 and Ex3 have their own .git folder, there would be considered as nested Git repos, and would be ignored by a git add.

If those .git are files, that would make them submodules.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Seems that will suffice my requirement. Does this mean I have to go to each Ex1 Ex2 folders and create a .git file? – Pasan W. Oct 18 '14 at 05:20
  • @PasanW no, I was saying "if you see a `.git` folder/file in those `Exn` folders, that would explain why a `git add` wouldn't work". Do you see a `.git` folder or file in those `Exn` folders? – VonC Oct 18 '14 at 05:22
  • There IS a .git directory in these Exn folders. Shall I delete them? – Pasan W. Oct 18 '14 at 05:24
  • @PasanW that would be one way indeed, but first, go in one of those `Exn` folder, and type "`git remote -v`", to see what their remote url is. If there is none, and you want only one bug repo, then yes, removing the `.git` folder would work (but would loose the individual history of those sub-repos) – VonC Oct 18 '14 at 05:25
  • Git remote -v inside an Exn folder gives:: origin ssh://git@ip/sandbox/pcccc.git (fetch) origin ssh://git@ip/sandbox/pccc.git (push) – Pasan W. Oct 18 '14 at 05:31
0

Pushing Folder to repository.

Step 1)Make sure you have a repository or create new one to which the folder will be pushed.

Step 2)Now in desktop go to that folder(which is to be uploaded).

Step 3)Now in that folder ; right click "Git Bash here".

Step 4)Type command :

$ git init
$ git add.
$ git config --global user.name <github user_name>
$ git commit -m "first commit"

IV.1)Add remote repository URL(in github account>your repository) to**

$ git remote add origin <paste the URL>

(URL looks like:https://github.com//.git

$ git push origin master

Step 5)Confirm

Step 6)Uploading takes place.Now refresh your repository in github account.

Step 7)Folder is uploaded .

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73