[英]Do I have to manually merge a branch with master after pushing the branch to github?
I am asking this question because I am slightly confused (only slightly).我问这个问题是因为我有点困惑(只是有点困惑)。
As I am using Pycharm
(on a branch other than master) it offers me the chance to commit and push changes of a branch to github.当我使用
Pycharm
(在 master 以外的分支上)时,它为我提供了提交分支的更改并将其推送到 github 的机会。
so I do just that.所以我就是这样做的。
Now...现在...
After , I run this:之后,我运行这个:
current branch *test
1.git pull origin master
2.git checkout master
3.git merge test
on 1.
it tells me all is up to date. 1.
它告诉我一切都是最新的。 then going on to 3.
it also tells me all up to date with master
.然后继续
3.
它还告诉我所有最新的master
。
Questions:问题:
EDIT编辑
master branch
master branch
git checkout test
.git checkout test
。 a message appears.出现一条消息。
switched to branch test. your branch is ahead of origin/test by 3 commits.
(use "git push" to publish your local commits)
git pull origin master
git pull origin master
a message appears with many lines showing the branch being updated.出现一条消息,多行显示正在更新的分支。
I re-run the command git pull origin master
我重新运行命令
git pull origin master
a message appears from http://github.com/username/project来自http://github.com/username/project的消息出现
I press the green button to commit changes and push.我按下绿色按钮提交更改并推送。 a pop-up appears
nothing to commit
弹出窗口似乎
nothing to commit
I run the command git checkout master
我运行命令
git checkout master
your branch is already up to date with origin/master您的分支已经与 origin/master 保持同步
I run the command git merge test
我运行命令
git merge test
ALL UP-TO-DATE !!!都是最新的!!!
so why git merge test
?那么为什么要
git merge test
呢?
on 1. it tells me all is up to date.
1. 它告诉我一切都是最新的。 then going on to 3. it also tells me all up to date with master.
然后继续到 3。它也告诉我所有与主人的最新情况。
$ git pull origin master
This commands does is equivalent to这个命令相当于
$ git fetch origin master
$ git merge master
The first step downloads all the changes from the master
branch in the origin
remote (which is a nickname for your GitHub repo).第一步从
origin
远程(这是您的 GitHub 存储库的昵称)中的master
分支下载所有更改。 The second command merges master
(which now includes any changes from GitHub) into the current branch ( test
).第二个命令将
master
(现在包括来自 GitHub 的任何更改)合并到当前分支 ( test
)。 Since you probably created the branch on master
and have not made any other changes, you get the message that everything is up-to-date.由于您可能在
master
上创建了分支并且没有进行任何其他更改,因此您会收到所有内容都是最新的消息。
I am not sure why step 3 says everything is up-to-date with master.我不确定为什么第 3 步说所有内容都与 master 保持同步。 You probably did other commands which you have not posted here, either to commit the same changes directly to
master
or merge test
previously.您可能执行了其他未在此处发布的命令,或者将相同的更改直接提交给
master
或之前的合并test
。
Questions:
问题:
- What happens when i commit-push a branch to github?
当我提交一个分支到 github 时会发生什么?
When you push a branch to GitHub, then you create that branch in your GitHub repo along with the entire change history which it represents.当您将分支推送到 GitHub 时,您会在 GitHub 存储库中创建该分支以及它所代表的整个更改历史记录。 Nothing changes with any other branches, including
master
.任何其他分支都没有任何变化,包括
master
。
Do i have to run the code block above after i push that branch to master?
在将该分支推送到 master 后,是否必须运行上面的代码块?
"push a branch to master" does not make any sense because master
is also a branch. “将一个分支推送到 master”没有任何意义,因为
master
也是一个分支。 You can only push a branch to a remote .您只能将分支推送到远程. Or you can merge one branch into another branch.
或者您可以将一个分支合并到另一个分支。
To update your GitHub repo with your local changes, you have two choices:要使用本地更改更新 GitHub 存储库,您有两种选择:
Merge your branch to master
manually and then push master
to GitHub with手动将您的分支合并到
master
,然后将master
推送到 GitHub
$ git checkout master $ git merge test $ git push origin master
Note that this only does steps 2 and 3 from your original commands.请注意,这仅执行原始命令中的第 2 步和第 3 步。 Your original Step 1 merges
master
into test
.您原来的 Step 1 将
master
合并到test
。 This is only necessary if master
has changes and you want to check for merge conflicts and resolve them if they exist.仅当
master
有更改并且您想要检查合并冲突并在它们存在时解决它们时才需要这样做。 Instead, you want to do the opposite: merge test
into master
.相反,您想要做相反的事情:将
test
合并到master
。 This is why I checkout master
first then merge test
.这就是为什么我先结帐
master
然后合并test
。
Push the branch to GitHub and create a Pull Request in your GitHub repo.将分支推送到 GitHub 并在您的 GitHub 存储库中创建拉取请求。 Then when you merge the PR,
master
on GitHub will be updated and you will need to pull the changes back to your local repo:然后,当您合并 PR 时,GitHub 上的
master
将更新,您需要将更改拉回本地存储库:
$ git checkout master $ git pull origin master
ps You can do the equivalent of all of these commands inside PyCharm if you wish. ps 如果您愿意,您可以在 PyCharm 中执行所有这些命令的等效操作。
Yes.是的。 you have to manually merge the branch .
您必须手动合并分支。 Because at the current state there are two branches in your repo.
因为在当前状态下,您的回购中有两个分支。 So if you want to merge the new branch to the master branch then
所以如果你想将新分支合并到主分支然后
git checkout master
git merge <your-new-branch>
git push -u origin master
This should do the job.这应该可以完成工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.