0

In my current directory, I git add origin and fetch. However, when I push, git push origin master does more than just push the current directory and all the subfolders. Somehow the origin and fetch are set to my parent directory.

So, in context, I have /goo/foo/bar/baz. I am in bar and I want only baz to show up in my GitHub. Instead, I somehow push /goo.

(In real life, I just devise practice to be pushed here).

funfuntime
  • 261
  • 1
  • 8

2 Answers2

1

If you git init has been done in /goo (ie you have a /goo/.git folder), being in bar/ and pushing doesn't mean: push only bar at the top of my remote GitHub repo.

It means: push whatever has changed in my /goo/... repo, respecting the structure within /goo/.

Check what is the root folder of your repo:

pwd
  /goo/foo/bar
cd "$(git rev-parse --show-toplevel)"
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, `goo` is the root folder. I remove the `remote` `origin and `fetch`. However, when I try to re-add `origin` and `fetch` into `baz`, `goo` becomes the root folder again. – funfuntime Nov 28 '14 at 09:41
  • @KevinC Adding/removing the remote has no effect on where the git repo is. I would rather git clone the remote repo elsewhere, and copy exactly what I need in that local repo. – VonC Nov 28 '14 at 09:58
0

You have to git remote remove fetch. BUT, git remote add origin <repo name>. Then, when you git push master, you should only get the current directory in github.

funfuntime
  • 261
  • 1
  • 8