本文主要介绍GIT标签同步脚本设置与使用SourceTree更方便的配置SSH 基本配置可以参考之前的Hexo搭建第5节。
复制下面的代码写成 .bat 文件
勾选(run command silently)
带入参数$REPO
git checkout master
git fetch --prune origin
git pull --rebase
cd %1
FOR /F %%i in ('git tag -l') DO git tag -d %%i
git fetch --tags origin
-----
cd %1
echo 'Remove all local tags'
FOR /F %%i in ('git tag -l') DO git tag -d %%i
echo 'Fetch tags from origin'
git fetch --tags origin
git同步原生标签命令可参考git指令
git tag | xargs git tag -d
git fetch --tags
此操作可以递归更新每个子模块,但不一定会 rebase 到子模块的最新 master (可能是 git 的 bug)
勾选(run command silently)
git submodule update --recursive --remote --rebase
使用 SourceTree 内建的软件 PuTTY Key Generator 来产生一对密钥(PuTTY Key Generator在安装SourceTree 时一并安装,此处无需另外安装。)
此方法可以解决 SourceTree Terminal 无法使用 SSH 的问题
亦可参考之前的Hexo搭建第5节
$ ssh-keygen -t rsa -C [这边可以打mail或者空着也行,这里将按照你提供的邮箱地址,创建一对密钥。]
Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
进入.ssh目录查看是否有密钥文件即可
~\.ssh
配置
config内容
Host github/gitee ip
HostName github domain
IdentityFile ~/.ssh/id_rsa
User pandaoh
确认是否可连接成功,可以输入下面的命令
ssh -T git@github.com
看看设置是否成功
如果是下面的反馈:
The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
不要紧张,输入yes就好,然后会显示成功(successful)。
将文件
accounts.json
放入%LocalAppData%\Atlassian\SourceTree\
。
[
{
"$id": "1",
"$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity",
"Authenticate": true,
"HostInstance": {
"$id": "2",
"$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountInstance, SourceTree.Host.AtlassianAccount",
"Host": {
"$id": "3",
"$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountHost, SourceTree.Host.AtlassianAccount",
"Id": "atlassian account"
},
"BaseUrl": "https://id.atlassian.com/"
},
"Credentials": {
"$id": "4",
"$type": "SourceTree.Model.BasicAuthCredentials, SourceTree.Api.Account",
"Username": "",
"Email": null
},
"IsDefault": false
}
]
修改完成后,Force Push 到远端即可。
修改完成后,Force Push 到远端即可。
修改完成后,Force Push 到远端即可。
以上教程均为 SourceTree 操作,其中修改过去的或者已提交的 commit 信息,原理基本都是修改了本地仓库的信息,再 Force Push 到远程。至于详细命令可参考 Git 教程。