我有直接推送到 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/