git 使用 ssh 协议 & 创建空分支

August 11, 2020 默认分类

use ssh

今天 git push 时突然要求输入账号密码
捣鼓了一下才发现用的https协议
(clone的时候糊涂了?)
https和ssh协议的话clone公开仓库当然不要鉴权
但是push的时候https只能账号密码鉴权
(ssh就很方便)

修改remote

$ git remote -v  //先看一看
$ git remote set-url <branchName> <remoteURI>

orphan branch

$ git checkout --orphan <new_branch>
Create a new orphan branch, named <new_branch>, started from and switch to it. The first commit made on the new branch will have no parents and it will be the root of a new history totally disconnected from all the other branchs and commits.
就是在当前分支下创建新分支,继承当前分支文件但不继承追踪。我们再使用:
$ git rm -rf .

清除当前文件即得空分支

添加新评论