英文:
How to sync my branch with develop branch in Git
问题
我在2023年6月2日通过克隆*develop*分支创建了一个名为*my-feature*的分支。在我正在处理*my-feature*分支时,其他开发者在2023年6月4日向*develop*分支推送了一些更改。现在我想将develop分支的最新代码合并到*my-feature*。
git checkout develop
git fetch
git checkout my-feature
git rebase develop
git push -f origin my-branch
它给出了以下提示
你已经是最新的,但develop分支的更改还没有合并到my-feature分支。
你可以告诉我如何将*my-feature*分支与develop分支进行合并吗?
英文:
I created a branch called my-feature branch on June 2, 2023 by cloning develop branch. while I am working on my branch my-feature branch other developer pushed some changes in *develop *branch on June 4, 2023. Now I want to get the latest code from develop branch to my-feature.
git checkout develop
git fetch
git checkout my-feature
git rebase develop
git push -f origin my-branch
It gives me
you are already up to date but the change in develop branch is not come to my-feature branch.
Can you tell me how to rebase my-feature branch with develop branch?
答案1
得分: 1
你从未实际更新本地的develop分支。git fetch检查远程的状态并更新你的仓库所理解的origin的最新状态(origin/develop)。我想如果你切回develop分支并运行git status,它会告诉你你落后于一些提交。
如果你用git pull而不是fetch,那么rebase会将更改带过来。(git pull是git fetch和git merge origin/<分支名称>或rebase的组合,具体取决于你的设置。)
英文:
You never actually updated your local develop branch. git fetch checks the state of the remote and updates what your repo understands as the latest of origin (origin/develop). I imagine if you go back to develop, and run git status it will say that you are behind some number of commits.
If you had done git pull instead of fetch, then the rebase would brought the changes over. (git pull is a combination of git fetch and git merge origin/<branch name> or rebase depending on your settings.)
答案2
得分: 0
不要 rebase。只需将 develop 合并到你的分支以保持其最新,并继续工作。假设你仍然在 my-feature 分支上:
git fetch
git merge origin/develop
对于你长时间正在开发的特性分支,定期执行这个操作是个好主意。请注意,合并提交不会影响将出现在拉取请求中的更改列表。
英文:
Don't rebase. Just merge develop into your branch to keep it up to date, and keep on working. Assuming you are still "on" my-feature:
git fetch
git merge origin/develop
It's a good idea to do this periodically for a feature branch that you are working on for a long time. Note that the merge commit will not have any effect on the list of changes that will appear in the pull request.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论