简体   繁体   中英

git push local file structure to the remote repo

I realized that the file structures (ie, 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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM