修剪原始分支不再存在于上游

时间:2016-07-02 08:40:34

标签: git git-branch git-fork

这些分支位于上游

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/gh-pages
  remotes/origin/master
  remotes/origin/next
  remotes/origin/translation
  remotes/origin/v1.0.1
  remotes/origin/videoConverter

这些是 my fork

的分支
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/beta
  remotes/origin/dashboardNewContent
  remotes/origin/externalUrl
  remotes/origin/gh-pages
  remotes/origin/master
  remotes/origin/next
  remotes/origin/rc
  remotes/origin/rc-0.3.0
  remotes/origin/release-candidate
  remotes/origin/streama-node
  remotes/origin/translation
  remotes/origin/v1.0.0
  remotes/origin/videoConverter
  remotes/upstream/gh-pages
  remotes/upstream/master
  remotes/upstream/next
  remotes/upstream/translation
  remotes/upstream/v1.0.1
  remotes/upstream/videoConverter

自从我分叉后,上游回购已经更新。我找不到从上游不再存在的fork中删除分支的方法。 This GitHub tutorial显示了如何同步提交历史记录。

这个问题是否有直接的解决方案?

1 个答案:

答案 0 :(得分:5)

一个技巧是用 camContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: dX = camContainer.getX() - event.getRawX(); dY = camContainer.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: float moveX=event.getRawX() + dX; float moveY=event.getRawY() + dY; if (moveX < 0) { moveX = 0; } if (moveX > screenX) { moveX = screenX; } if (moveY < 0) { moveY = 0; } if (moveY > screenY) { moveY = screenY; } camContainer.animate() .x(moveX) .y(moveY) .setDuration(0) .start(); break; default: return false; } return true; } }); url替换本地仓库中的origin(引用你的前叉):

upstream

然后单个命令git remote rename origin ori git remote add origin $(git remote get-url upstream) 将在本地删除所有过时的远程跟踪分支(git fetch --prune不在remotes/origin/xxx中,暂时由“upstream”引用<) / p>

最后,您可以为每个origin分支检查remotes/ori/xxx是否存在。如果不是:remotes/origin/xxx

类似的东西:(在bash中)

git push --delete ori xxx

该脚本可以放在for f in $(git for-each-ref refs/remotes/ori --format '%(refname:short)' | sed 's,ori/,,') do; git rev-parse -q --verify refs/remotes/origin/$f >/dev/null || git push --delete ori ${f} done (或任何git-cleanup名称)中,并使用git-xxx(或git cleanup)进行调用。这样,即使在Windows上,它也可以在自己的bash中运行。

完成:

git xxx