【问题标题】:Replace the contents of one directory in GIT替换git中一个目录的内容
【发布时间】:2012-09-06 10:08:39
【问题描述】:

假设我有一个包含目录 Dir1 和 Dir2 的存储库,并且我在 branchA 中。

假设我想去掉 Dir2 的内容并在 master 分支中用 Dir2 替换它们,同时保留 Dir1 的内容。

我不希望这会那么简单,但理想情况下:

cd Dir2
git [magic that replaces current dir with the contents of master branch]

【问题讨论】:

标签: git


【解决方案1】:

branchA 中删除Dir2
master 分支获取它:

$ git checkout branchA
$ git rm -r Dir2
$ git checkout master -- Dir2
$ git commit -m "replaced Dir with Dir2 from master"

【讨论】:

  • 酷!我的印象是您必须检查整个存储库。你碰巧知道如何在 eGit 或 TortoiseGit 中做到这一点?
  • 是否可以与另一个上游一起做? git checkout notorigin:master -- Dir2
猜你喜欢
  • 2017-09-26
  • 2021-12-12
  • 2016-10-18
  • 1970-01-01
  • 1970-01-01
  • 2015-07-17
  • 1970-01-01
  • 2012-02-28
  • 2015-01-08
相关资源
最近更新 更多