从分支拉出,然后推到另一个分支

时间:2021-07-14 16:23:54

I have a 'master' branch, and a 'bugfix' branch. this bugfix branch needs to be always updated with master commits, but i need to push to its own branch.

我有一个'master'分支和一个'bugfix'分支。这个bugfix分支需要始终使用主提交更新,但我需要推送到自己的分支。

i tried

我试过了

git branch -f --track bugfix origin/master

and tried set-upstream too but seems to set both, pull and push from/to 'master'.

并且尝试了set-upstream,但似乎设置了两者,拉/推/从'到'主'。

2 个解决方案

#1


1  

If you pull the remote master branch into master by doing a git pull you can push it to the remote bugfix branch like this:

如果你通过执行git pull将远程主分支拉入master,你可以将它推送到远程bugfix分支,如下所示:

git push origin master:bugfix

That is assuming the name of your remote is origin.

假设您的遥控器的名称是原点。

I hope this is what you meant.

我希望这就是你的意思。

#2


1  

How about

怎么样

mkdir -p git
cd git
git clone https://github.com/user/repo.git
cd repo
git branch bugfix
git checkout bugfix
git push origin bugfix
git checkout master

git branch --set-upstream-to=bugfix
echo 'hallo' > hallo.txt
git add hallo.txt
git commit -m 'lolz'
git config push.default upstream
git push

So it will push master to origin/bugfix and pull origin/bugfix to bugfix.

所以它会将master推送到origin / bugfix并将origin / bugfix拉到bugfix。

#1


1  

If you pull the remote master branch into master by doing a git pull you can push it to the remote bugfix branch like this:

如果你通过执行git pull将远程主分支拉入master,你可以将它推送到远程bugfix分支,如下所示:

git push origin master:bugfix

That is assuming the name of your remote is origin.

假设您的遥控器的名称是原点。

I hope this is what you meant.

我希望这就是你的意思。

#2


1  

How about

怎么样

mkdir -p git
cd git
git clone https://github.com/user/repo.git
cd repo
git branch bugfix
git checkout bugfix
git push origin bugfix
git checkout master

git branch --set-upstream-to=bugfix
echo 'hallo' > hallo.txt
git add hallo.txt
git commit -m 'lolz'
git config push.default upstream
git push

So it will push master to origin/bugfix and pull origin/bugfix to bugfix.

所以它会将master推送到origin / bugfix并将origin / bugfix拉到bugfix。