[关闭]
@946898963 2021-06-10T01:07:54.000000Z 字数 615 阅读 399

分支操作

Git


git 查看本地已有分支情况:

  1. git branch -a

拉取更新远程分支列表

  1. git remote update origin --prune

使用以下命令同步分支列表:

  1. git fetch -p
  2. -p 的意思是“精简”。这样,你的分支列表里就不会显示已远程被删除的分支了。

拉取远程分支并创建本地分支

  1. git checkout -b 本地分支名x origin/远程分支名x

git 获取更新远程分支列表并检出指定分支

删除本地分支

  1. git branch -d localBranchName

当一个分支被推送并合并到远程分支后,-d才会本地删除该分支。如果一个分支还没有被推送或者合并,那么可以使用-D强制删除它。

删除远程分支

  1. git push origin --delete remoteBranchName
  2. 如果你得到以下错误消息,可能是因为其他人已经删除了这个分支。
  3. error: unable to push to unqualified destination: remoteBranchName The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'git@repository_name'

Git 操作——如何删除本地分支和远程分支

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注