3

现在,当我想快速修复我的项目时,我会这样做:

# create and switch to this new branch
git checkout -b fixes-20130828-01
# push the new branch back to the origin
git push origin fixes-20130828-01
# link local and remote branches
git --set-upstream fixes-20130828-01 origin/fixes-20130828-01 

我希望能够通过以下方式执行上述操作:

# is there a way to get this to not only create and switch locally,
# but also to link to remote
git checkout --[something] fixes-20130828-01
# and then this would do the actual push to create
# the branch on the origin, now that it's logically linked up
git push

这将更容易使用、记忆,也更容易向新团队成员解释等,即“您使用此命令基于现有分支创建新分支,然后像往常一样将其推回。”

是否有开箱即用的选项?

4

1 回答 1

5

我认为你必须分两步完成。我不知道一种方法可以做到这一点。

git checkout -b my-new-branch
git push -u origin my-new-branch

(-u 选项设置上游跟踪。)

于 2013-08-29T00:07:01.413 回答