Git分支转移问题和工作流程 [英] Git Branch Diversion Issue and workflow

查看:87
本文介绍了Git分支转移问题和工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑我遵循的工作流程是否正确,或者我是否弄错了情况.

I have a doubt whether the workflow that I follow is correct or if I have messed up the situation.

我正在本地和远程创建的分支上开发一项新功能.我是唯一从事此工作的人.

I was working on a new feature on the branch that i created locally and on remote. I am the only person working on it.

我使用以下方法创建了它:

I Created it using:

git checkout -b rotation upstream/master

现在我进行更改并提交:

Now I made changes and commited:

git commit

并将更改推送到远程分支:

and changes were pushed to remote branch:

git push origin rotation

我的问题现在开始.我此时输入git fetch upstream.

My problem starts now. I typed git fetch upstream at this point.

现在,当我git status得到时,

vinayan@vinayan-MS-7623:~/QgisGitWorking/Quantum-GIS$ git status
# On branch rotatation
# Your branch and 'upstream/master' have diverged,
# and have 4 and 5 different commits each, respectively.
#
nothing to commit (working directory clean)

我对分支分歧消息感到困惑.

I am confused by the branch diverged message.

  1. 这里有什么问题吗?
  2. 如果我继续会不会有问题 在这里提交更改并向上游推?
  3. 如果出了什么问题,纠正它的最佳方法是什么?
  1. Is anything wrong here?
  2. Is there going to be an issue if i continue committing changes here and push upstream?
  3. If something is wrong, what would be the best way to correct it?

我对git很陌生.以前我只用过VSS.

I am quite new to git. Previously I have only used VSS.

vinayan@vinayan-MS-7623:~/QgisGitWorking/Quantum-GIS$ git remote -v
origin  git@github.com:vinayan/Quantum-GIS.git (fetch)
origin  git@github.com:vinayan/Quantum-GIS.git (push)
upstream    git://github.com/qgis/Quantum-GIS.git (fetch)
upstream    git://github.com/qgis/Quantum-GIS.git (push)

推荐答案

upstream的思想是允许您自己的存储库以upstream存储库中的最新存储库为基础.
这样,您可以与上游保持最新,同时将自己的贡献推送到"origin"(这是一个分叉:您拥有的upstream回购的克隆).

The idea of upstream is to allow for your own repo to rebase itself on top of latest from upstream repo.
That way, you can keep up-to-date with upstream, while pushing your own contribution to 'origin' (which is a fork: a clone of upstream repo which you own).

您可以按origin键.您不能推送到upstream(您不是贡献者)
请参阅" upstream?"

You can push to origin. You can't push to upstream (you are not a contributor)
See "What is the difference between origin and upstream in GitHub?"

我建议您使用,因为upstream/master有其自己的历史记录(与您的更改平行)

In your case, I would recommend, since upstream/master has its own history (parallel to your changes)

git checkout rotation
git rebase upstream/master
git push -f origin rotation

请注意,您正在用力推动(即重新创建更改的历史记录)在叉子上origin/rotation:如果尚未从叉子上拉出其他贡献者,那么这应该不是问题.
您在rotation上的工作将基于最新的upstream/master,这将简化

Note that you are force pushing (ie, recreating the history of your changes) on your fork origin/rotation: if no other contributor have already pulled from your fork, this shouldn't be an issue.
And your work on rotation will be based on the latest of upstream/master, which will simplify the future pull request you might want to do.

这篇关于Git分支转移问题和工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆