确认 git 合并策略



我在堆栈和互联网上查看了一堆关于merging an existing directoryinto an existing git repository最佳实践的文档。

据我所知,将现有目录放入 git 存储库的最佳策略是:

  • cd ~/path/to/existing/directory

  • 执行命令git init

  • 执行命令git add . && git commit -m'pushing existing directory into repo'

  • 执行命令git remote add origin https|ssh:path/to/the/repository.git
  • 执行命令git pull origin master
  • 执行命令git push origin master

现在在这一点上,我应该将现有目录合并到 Git 存储库中,现有目录覆盖优先,并链接到 Git 存储库。 现有目录和存储库文件中的冲突怎么办?

有人可以确认这是正确的策略吗?

如果没有,我的下一个策略是:

  • mv existingdirectory to existingdirectorybak
  • 将 git 存储库克隆到单独的目录中
  • cp 现有目录 bak 到克隆目录
  • 推送更改
  • MV 将目录克隆到现有目录中

我可能错过了一些东西,但这是我要做的:

  1. 在现有存储库文件夹中创建一个新分支:git checkout -b branchX
  2. 将现有目录复制到 git 目录
  3. git add --all
  4. git commit -am 'New files! Yeah.'

最新更新