简体   繁体   English

如何从上游分支合并?

[英]How to merge from upstream branch?

Here is my git setup (we use Git + Atlassian Stash in our corporate network): 这是我的git设置(我们在公司网络中使用Git + Atlassian Stash):

upstream:
  master

origin (my fork of 'upstream'):
  master
  branch1 (branch of master, with a few commits on top of it)

clone (local; clone of 'origin'):
  master
  branch1 (ahead of 'origin:branch1' by 1 commit)

What I want to do: 我想做的事:

I want to merge upstream:master -> clone:branch1 . 我想合并upstream:master -> clone:branch1 I know there will be conflicts with this merge (since I changed files in my branch1 that others have changed in upstream). 我知道此合并会存在冲突(因为我更改了branch1中的文件,而其他文件在上游已更改)。 Once this is done I hope to push my changes back to origin:branch1 , which will include my 1 commit + latest base from upstream (I want to keep up to date with the master branch, since that's the one I branched from). 完成此操作后,我希望将更改推回origin:branch1 ,其中将包括上游的1 commit +最新库(我想跟master分支保持最新,因为那是我分支的分支)。 Along with this I want it to be a rebase, so that the commit history is clean and doesn't spider-web all over the place. 与此同时,我希望它成为一个变基,以便提交历史记录是干净的,并且不会在所有地方产生蜘蛛网。

Another note is that I do not use git command line directly. 另一个注意事项是,我不直接使用git命令行。 On Windows, I'm using SmartGit, so if anyone knows instructions for that tool that would be most ideal. 在Windows上,我使用的是SmartGit,因此,如果有人知道该工具的说明,那将是最理想的选择。

How can I properly merge like I have described above? 我如何像上面描述的那样正确合并?

If no one else has cloned or is working with branch1, you can rebase it on top of master, once you have updated master to upstream/master. 如果没有其他人克隆或正在与BRANCH1,你可以重订它主人的顶部,一旦你已经更新的主上游/大师。

  • First, fetch upstream (SmartGit: Remote/Pull, select "Fetch Only") 首先, upstream获取 (SmartGit:“远程/拉”,选择“仅获取”)
  • Then reset master to upstream/master (SmartGit: Local/Reset) 然后将master重置为upstream/master (SmartGit:本地/重置)
  • Now rebase branch1 on top of master (SmartGit: In the Branches view, you can right-click on a branch like master and select Rebase HEAD to rebase your current HEAD onto the selected branch master ) 现在将branch1重新设置为master的基础(SmartGit:在Branches视图中,您可以右键单击像master这样的分支,然后选择Rebase HEAD以将当前的HEAD重新基础到所选的分支master
    Resolve merge conflicts if necessary. 如有必要, 解决合并冲突
  • Finally push (force the push) of branch1 to origin (SmartGit: In the context menu of the Branches view, you can invoke Push and Push To on local branches). 最后,将branch1推送(强制推送)到origin (SmartGit:在Branches视图的上下文菜单中,您可以在本地分支上调用PushPush To )。

在此处输入图片说明

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

相关问题 如何将master合并到github中的Windows分支中? - how to merge master into branch in github for windows? 如何查看更改列表以从上游/源获取,或更改推到上游/源 - How to view list of changes to fetch from upstream/origin, or changes to push to upstream/origin 使用git-svn创建上游分支时无法进行身份验证 - Unable to authenticate when creating upstream branch using git-svn GIT:如何使用 git 命令获取从主分支到自定义分支的最新更改? - GIT : How to get latest changes from master branch to the custom branch using git commands? 如何将更改从master转移到Feature分支 - How can I get changes from master into feature branch 在Windows上进行Dockererized Kong操作,显示“从上游服务器收到无效响应” - Dockererized Kong on windows giving “An invalid response was received from the upstream server” 如何将上游构建的二进制文件传递给远程下游构建从属服务器 - How to pass binaries built upstream to a remote downstream build slave 如何合并所有子目录中具有相同名称的文本文件? - How to merge text files with the same name from all subdirectories? 如何使用Windows Batch从多个文件夹合并多个文件 - How to Merge Multiple Files from Multiple folders using Windows Batch 如何从git导出所有分支更改的文件与本地主文件相比 - how to export all branch changed files compared to local master from git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM