简体   繁体   English

如何从源提交到我的本地分支?

[英]How do I get commits from origin into my local branch?

I have a fork ("origin") of a project on github ("upstream").我在github(“上游”)上有一个项目的分支(“起源”)。 I have a branch ( mybranch ), which I pushed to origin and created a pull request from.我有一个分支( mybranch ),我将其推送到 origin 并从中创建了一个拉取请求。

Now, someone pushed to my branch on my fork.现在,有人用我的叉子推到了我的分支。 This means, mybranch on origin is ahead of my local mybranch by x commits.这意味着, mybranch上的mybranch比我本地的mybranch领先x 次提交。

How do I get those commits into my local branch, as single commits.我如何将这些提交作为单个提交放入我的本地分支。

I've seen solutions of deleting my local branch and using git reset --hard origin/master , but that just doesn't feel right.我已经看到了删除本地分支并使用git reset --hard origin/master解决方案,但这感觉不对。 Is there a more natural solution?有没有更自然的解决方案?

someone pushed to my branch on my fork.有人用我的叉子推到我的树枝上。 This means, mybranch on origin is ahead of my local mybranch by x commits.这意味着,起源上的 mybranch 比我本地的 mybranch 领先 x 次提交。

Then a simple git pull --rebase is enough: it will update your local branch with the remote ones, and replay any local commits (done on your local branch but not yet pushed) on top of those new commits.然后一个简单的git pull --rebase就足够了:它将使用远程分支更新您的本地分支,并在这些新提交之上重放任何本地提交(在您的本地分支上完成但尚未推送)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的提交从“无分支”“移动”到实际分支? - How do I "move" my commits from "no branch" to an actual branch? 如何在不提交的情况下从git中的分支获取更改? - How do I get the changes from a branch in git without the commits? 如果我忘记推送提交并从本地开发分支创建功能分支,如何解决 GIT 冲突? - How to resolve GIT conflict if I forgot to push the commits and created a feature branch from my local develop branch? 如何在本地分支领先于原始提交时查看git提交 - How to view git commits when local branch is ahead of origin Commits 如何从原产地到上游建立相同的分支? - How do I make the same branch from my origin to upstream? git reflog显示我与我的分支无关的提交。 如何获得与我检查过的分支相关的提交? - git reflog shows me commits unrelated to my branch. How do I get the commits related to the branch I have checked out? 如何从原点获取特定功能分支? - How do I get a particular feature branch from origin? 如何在没有额外提交的情况下确保我的本地分支跟踪远程相同? - How do I ensure that my local branch tracking remote is identical without additional commits? 如何压缩本地分支上的特定提交? - How do I squash specific commits on a local branch? 在使用 git-worktree 时,如何将分支从原点拉到本地? - How do I pull a branch from origin to local while working with git-worktree?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM