Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.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_Visual Studio_Azure Devops_Git Bash - Fatal编程技术网

有没有办法将git repo合并到现有目录中?

有没有办法将git repo合并到现有目录中?,git,visual-studio,azure-devops,git-bash,Git,Visual Studio,Azure Devops,Git Bash,我在VSTS MyRepoX中配置了一个repo。该回购协议只有一个自述文件。我有一个本地VisualStudio解决方案,我想将其包含在目录中,然后我需要确保这两个源在推送和拉送时同步。要执行此操作,我可以采取哪些步骤?您需要将本地文件夹转换为Git repo,添加一个远程文件夹,然后将两者同步 在本地文件夹中 git init git add . git commit -m "initial commit" git remote add origin url-to-remote-repo g

我在VSTS MyRepoX中配置了一个repo。该回购协议只有一个自述文件。我有一个本地VisualStudio解决方案,我想将其包含在目录中,然后我需要确保这两个源在推送和拉送时同步。要执行此操作,我可以采取哪些步骤?

您需要将本地文件夹转换为Git repo,添加一个远程文件夹,然后将两者同步

在本地文件夹中

git init
git add .
git commit -m "initial commit"
git remote add origin url-to-remote-repo
git fetch origin master
git branch --set-upstream-to=origin/master master
git pull --rebase
git push

我还建议您在执行任何操作之前添加一个标准的VisualStudio,这样您就不会在repo中获得二进制文件/包

Daniel Mann的答案很好,但另一种方法是将repo克隆到一个新文件夹,然后将源文件复制到其中:

git clone http://my.repo.url/
此git命令将repo克隆到与repo同名的新文件夹中。您需要确保源代码所在的文件夹具有不同的文件夹名称

然后只需将源文件复制到新克隆的文件夹中,并运行以下Git命令:

git add .
git commit -m "initial commit"
git push

绝对同意您应该按照Daniel的建议在“git add.”之前添加一个.gitignore文件。

您是否按照Daniel所说的方式成功提交并将现有目录的更改推送到VSTS git repo?太好了,这很有效。你能解释一下提取和分支步骤的原因吗?我是git新手,我想更好地理解为什么会在这种情况下使用git