git - 在小组工作时如何为我的 pull 请求维护一个分支?

标签 git bitbucket

我有直接推送到 master 的权限,但在我的团队中,我们遵循一种更礼貌的机制:

  • git pull
  • git checkout -b myBranch
  • git merge master
  • 做我的事情...git add...等等
  • git push origin myBranch --force
  • 然后在 bitbucket web GUI 上“询问”一个 Pull Request

但我想知道是否有更直接的方式来表达“我不再需要 myBranch 的本地副本,就好像它是一个新分支,也适用于远程分支”

我读过 Can I destroy and recreate a Git remote branch in one command?我可以接受远程删除,但是 rebase 的事情让我有点不知所措。

编辑:另外,如果当前的工作方式导致同步错误,我想知道

最佳答案

I don't want the local copy of myBranch anymore, just act as if it were a new branch, also for remote

如果你只是想要一个全新的分支myBranch来自当前的主人(失去所有 myBranch 的历史):

git fetch
git checkout -B mybranch origin/master

该命令将重置您的分支:来自 git checkout :

If -B is given, <new_branch> is created if it doesn’t exist; otherwise, it is reset.
This is the transactional equivalent of:

$ git branch -f <branch> [<start point>]
$ git checkout <branch>

然后:

# work

# Before pushing, make sure you are up-to-date
git fetch
git rebase origin/master
git push --force -u origin myBranch

远程分支将重置为您的新 myBranch历史。

关于git - 在小组工作时如何为我的 pull 请求维护一个分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34311801/

相关文章:

git - 为什么 git 不显示我的文件已修改?

bitbucket - 如何从Bitbucket备份问题列表?

ios - 在 git 中取消暂存先前提交中的文件

Git:撤消本地更改;混帐添加。 + 混帐室?

git - 为新的未跟踪文件生成 git diff

git - 在 GIT 中模拟冲突

tortoisehg - 如何浏览 Bitbucket 上的公共(public)存储库?

java - 从 Java 应用程序以编程方式访问 Atlassian BitBucket

python - 如何使用 ssh 为 bitbucket/github 从私有(private)仓库下载文件?

git - 使用 git clone --mirror 和 git push --mirror move git repo