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

use*_*458 3 git visual-studio git-bash azure-devops

我在 VSTS MyRepoX 中配置了一个 repo。这个 repo 只有一个自述文件。我有一个本地 VisualStudio 解决方案,我想将它包含在目录中,然后我需要确保这 2 个源对于推送和拉取是同步的。我可以采取哪些步骤来做到这一点?

Dan*_*ann 10

您需要将您的本地文件夹变成一个 Git 存储库,添加一个远程,然后将两者同步。

在您的本地文件夹中,

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
Run Code Online (Sandbox Code Playgroud)

我还建议.gitignore您在执行任何操作之前添加一个标准的 Visual Studio ,这样您就不会在您的存储库中获得二进制文件/包。