[英]How to pull a branch from remote when you accidentally deleted local branch?
I have 3 branches and i have pushed all the 3 branches to remote git [ aka bitbucket am using bb]. 我有3个分支,我已将所有3个分支推送到远程git [aka bitbucket我正在使用bb]。 I deleted a branch locally now using
git branch -d <branch-name>
我现在使用
git branch -d <branch-name>
在本地删除了一个分支
I did a git push also . 我也做了一个git push。 But now i want all the branches to be present in my local system.
但是现在我希望所有分支都出现在我的本地系统中。
Since you pushed the branches you can create a local branch that is tracking the remote with: 自从推送分支以来,您可以创建一个本地分支,该分支通过以下方式跟踪远程:
git branch --track <local branch name> <remote branch name>
Your remote branch names will be something origin/foo
and you can see the list of them with git branch -r
您的远程分支名称将是一个
origin/foo
,您可以使用git branch -r
查看它们的列表。
https://www.kernel.org/pub/software/scm/git/docs/git-branch.html https://www.kernel.org/pub/software/scm/git/docs/git-branch.html
For adding all the remotes in one line you can do the following: 要在一行中添加所有遥控器,您可以执行以下操作:
git branch -r | egrep -v "(HEAD|master)" | sed -e "s/origin\///" | xargs -I % git branch --track % origin/%
This gets a list of all the remote branches except HEAD and master. 这将获得除HEAD和master之外的所有远程分支的列表。 Then creates a new local version with the same name that will track the remote.
然后创建一个具有相同名称的新本地版本,该版本将跟踪远程服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.