【发布时间】:2020-09-26 04:34:35
【问题描述】:
我一直在向自己介绍 git,但如果我要与其他人一起参与一个项目,我无法理解如何组装我的工作流程。
假设我的任务是为现有代码库创建新的更新。我会首先从远程存储库中提取,创建一个新分支,进行更改,提交,合并到我自己的主存储库,最后推送到远程存储库。但是,一旦我的队友查看了代码并认为它很好,我希望将我所做的更改合并到远程仓库中。因此,在这种情况下,理想情况下,我可以在主版本的远程存储库上创建另一个分支,并将我在本地所做的更改推送到该分支,以便我的队友可以查看它。一旦他们认为没问题,我希望能够将远程仓库上的那个分支合并到主版本中。
所以就我的命令而言,它看起来像:
git pull
git checkout -b new_update_branch
//make changes to code, etc.
git add *
git commit -m "update finished"
git checkout master
git merge new_update_branch
//somehow push the changes to a new branch on the remote repository
//i.e. create a branch on the remote repository too
//teammates look at this branch on the remote repository and ok it
git push origin master
我将如何在远程存储库上创建一个分支,这样它也不会影响 master?
【问题讨论】: