Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git将本地文件结构推送到远程repo_Git - Fatal编程技术网

git将本地文件结构推送到远程repo

git将本地文件结构推送到远程repo,git,Git,在我将.git移动到父目录后,我意识到github repo中的文件结构(即repo中每个文件的路径)与本地repo不同。例如我以前的回购协议是src/格式的,看起来像: repo/src/.git repo/src/repofiles.c 在发出以下命令之后 repo/src$ls -a repofiles.c .git repo/src$mv .git .. repo/src$cd .. repo$mkdir example repo$touch example/example1.

在我将.git移动到父目录后,我意识到github repo中的文件结构(即repo中每个文件的路径)与本地repo不同。例如我以前的回购协议是src/格式的,看起来像:

repo/src/.git
repo/src/repofiles.c
在发出以下命令之后

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
现在在远程回购中,我有根文件夹

repo/src/repofiles.c
repo/src/.git 
repo/src/example/example1.c
然而,我希望我的本地结构具有以下结构:

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

不一致的文件结构使程序无法为用户运行。

这不是移动
.git
的方式

您不移动
.git
,而是移动所有其他内容以匹配您的目标结构

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
然后,检查github回购协议是否反映了新的结构

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
在本地,将您的回购文件夹移动到旧文件夹中,然后再次克隆

mv repo repo.old
git clone github/yourrepo repo
这样,您将得到: