如何从现有的远程分支创建本地分支

如何从现有的远程分支创建本地分支

本文介绍了如何从现有的远程分支创建本地分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从现有的远程分支(例如remote-A)创建一个分支,然后将更改提交到存储库.

I want to create a branch from an existing remote branch (let's say remote-A) and then commit the changes to the repository.

我已经使用以下命令从现有的Remote-A创建本地分支

I have used the below commands to create a local branch from the existing remote-A

$git checkout remote-A

git branch
master
* remote-A

现在我已使用以下命令从远程A创建了本地B

Now I have created local-B from Remote A using the below commands

git branch local-B
git checkout local-B

如何确保对本地B所做的更改位于远程A的顶部,以便在将本地B推送至远程仓库时,所做的更改位于远程A的顶部?

How do I make sure the changes I have on local-B are on top of remote-A so that when I push local-B to the remote repo, the changes are on top of remote-A?

推荐答案

您要在remote-A的基础上创建分支,对其进行更改,然后将其推送到remote-A?

you want to create branch on base of remote-A, make changes on it and then push them on remote-A?

git checkout -b remote-A
git pull origin remote-A
git checkout -b remote-B

在远程B上进行更改

 git commit -a -m 'describe changes on remote-B branch'

 git checkout remote-A
 git merge remote-B
 git push origin remote-A

这篇关于如何从现有的远程分支创建本地分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 19:34