【问题标题】:Confirm git merge strategy确认 git 合并策略
【发布时间】:2020-02-05 05:03:56
【问题描述】:

我在堆栈和互联网上查看了一堆关于 merging an existing directory into 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 存储库的链接。现有目录和 repo 文件的冲突怎么办?

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

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

  • mv existingdirectory to existingdirectorybak
  • 将 git repo 克隆到单独的目录中
  • cp existingdirectorybak 到克隆目录
  • 推送更改
  • mv 将目录克隆到现有目录中

【问题讨论】:

    标签: git github merge git-merge


    【解决方案1】:

    我可能遗漏了一些东西,但我会这样做:

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

    【讨论】:

      猜你喜欢
      • 2018-09-08
      • 2020-11-21
      • 2023-02-11
      • 1970-01-01
      • 2012-07-05
      • 2012-05-09
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多