在小组工作时如何为我的拉取请求维护一个分支?
How to maintain a branch just for my pull requests when working in group?
我有直接推送到 master 的权限,但在我的团队中,我们遵循一种更礼貌的机制:
git pull
git checkout -b myBranch
git merge master
- 做我的事情...git 添加...等等
git push origin myBranch --force
- 然后 "ask" 在 bitbucket web GUI 上一个 Pull Request
但我想知道是否有更直接的说法"I don't want the local copy of myBranch anymore, just act as if it were a new branch, also for remote"
我读过 Can I destroy and recreate a Git remote branch in one command? 并且我可以远程删除,但是变基的东西让我有点不知所措。
编辑:另外,如果当前的工作方式导致同步错误,我想知道
我有一些文字供您阅读:-)
好文章,分支机构如何在开发中取得成功。
根据您提供的初始步骤以及您的评论,以下是我在开始新功能或错误修复时将采取的步骤:
git checkout master
git pull
git checkout -b myBranch
... do work ... add/commit/etc
... periodically when you want to get the latest from master...
git fetch
git rebase origin/master
git push --force origin myBranch
在变基步骤中,当然你可以有代码冲突,就像合并一样。解决这些冲突的过程将非常相似。 Git 提供有关如何执行这些步骤的说明。
因此,这些步骤与您最初发布的步骤非常相似,但 rebase 将使您的历史更清晰(与合并相反),因为它可以防止无意义的合并提交。
I don't want the local copy of myBranch
anymore, just act as if it were a new branch, also for remote
如果你只是想要一个全新的分支 myBranch
来自当前的 master(丢失 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
历史记录。
我有直接推送到 master 的权限,但在我的团队中,我们遵循一种更礼貌的机制:
git pull
git checkout -b myBranch
git merge master
- 做我的事情...git 添加...等等
git push origin myBranch --force
- 然后 "ask" 在 bitbucket web GUI 上一个 Pull Request
但我想知道是否有更直接的说法"I don't want the local copy of myBranch anymore, just act as if it were a new branch, also for remote"
我读过 Can I destroy and recreate a Git remote branch in one command? 并且我可以远程删除,但是变基的东西让我有点不知所措。
编辑:另外,如果当前的工作方式导致同步错误,我想知道
我有一些文字供您阅读:-)
好文章,分支机构如何在开发中取得成功。
根据您提供的初始步骤以及您的评论,以下是我在开始新功能或错误修复时将采取的步骤:
git checkout master
git pull
git checkout -b myBranch
... do work ... add/commit/etc
... periodically when you want to get the latest from master...
git fetch
git rebase origin/master
git push --force origin myBranch
在变基步骤中,当然你可以有代码冲突,就像合并一样。解决这些冲突的过程将非常相似。 Git 提供有关如何执行这些步骤的说明。
因此,这些步骤与您最初发布的步骤非常相似,但 rebase 将使您的历史更清晰(与合并相反),因为它可以防止无意义的合并提交。
I don't want the local copy of
myBranch
anymore, just act as if it were a new branch, also for remote
如果你只是想要一个全新的分支 myBranch
来自当前的 master(丢失 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
历史记录。