Chenming Zhang
Chenming Zhang

Reputation: 2556

git push local file structure to the remote repo

I realized that the file structures (i.e., path of each file in the repo) in github repo is different from the local repo, after I moving .git to the parent directory. for example. my previous repo is in src/ and looks like:

repo/src/.git
repo/src/repofiles.c

after issusing the following commands

repo/src$ls -a
    repofiles.c .git
repo/src$mv .git ..
repo/src$cd ..
repo$mkdir example
repo$touch example/example1.c  && git add example/example1.c
repo$ls -a
   src example .git
repo$git commit -a && git push www.github

now in the remote repo, I have root folder with

repo/src/repofiles.c
repo/src/.git 
repo/src/example/example1.c

However i wish to have the following structures as my local structure has:

repo/src/repofiles.c
repo/examples/example.c
repo/.git/

the non-consistence file structure make the program not running for users.

Upvotes: 1

Views: 885

Answers (1)

VonC
VonC

Reputation: 1323343

That is not how you move a .git.

You don't move .git, you move everything else to match your target structure.

repo/src$ls -a
    repofiles.c .git

mkdir src                # I know: src/src but bear with me here
git mv repofiles.c src
mkdir example
touch example/example1.c  && git add example/example1.c
git commit -A && git push www.github

Then, check that the github repo reflect the new structure.

Locally, move your repo folder into an old one, and clone again

mv repo repo.old
git clone github/yourrepo repo

That way, you end up with:

repo/src/repofiles.c
repo/examples/example.c
repo/.git/

Upvotes: 1

Related Questions