0

有几个分支分支(master、test1、test2、)

我刚刚克隆了整个存储库,并想“同步” test1 和 test2 分支。远程,test1 具有所需的内容,test2 已过时。我想:

  1. 删除 test2 分支中的文件(本地和远程)
  2. 将 test2 与 test1 同步/合并,以便 test2 与 test1 具有相同的内容,删除 test2 的当前内容。

所以换句话说,我将如何提取 test1 的内容并将其放入 test2(销毁 test2 的所有当前内容)。

4

1 回答 1

2

我可能会这样做:

git branch -d test2   # Delete test2 locally
git checkout test1
git checkout -b test2 # Recreate test2 locally from test1
git push -f           # Forcibly bring remote test2 into step

但请记住通常的警告;如果其他人有上游test2,那么覆盖它的历史就不是很友好。

于 2013-01-03T11:45:30.580 回答