git 命令备忘
1. 自定义输入用户密码clone项目:
git clone https://user:[email protected]
git回退
- 先获取要回退的版本号,eg:aaa
git reset --hard aaa
hard的方式会丢弃本地做出的所有修改和服务器保持一致,并将head指针指向回退的版本号;- 此时可以有两种操作:
a. 直接暴力提交:git push -f orgin
这种提交方式回退部分的日志记录会消失;
b. 重置head指针到回退前的版本号, eg: bbb
git reset --mixed bbb
mixed这种方式不会放弃本地修改,将head指针指向指定版本号;
然后直接push即可:git push orgin
这种方式会保持回退的提交记录,更利于版本变迁的管理;
git中同时向多个远程仓库推送
- 新增一个本地仓库;
- 定义一个远程仓库a;
- 进入仓库的
.git
文件夹中, 打开config
文件;修改如下:
<!-- 该文件已是完成修改的版本,在remote下新增url即可,这样不配置多个远程仓库的好处是:
仅一次提交就可以同时维护多个仓库的代码,使之保持一致 -->
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[branch "master"]
remote = orgin
merge = refs/heads/master
[remote "orgin"]
url = https://github.com/xxx/aaa.git
url = https://gitee.com/xxx/aaa.git
fetch = +refs/heads/*:refs/remotes/orgin/*
git 常见问题汇总
- 克隆项目提示如下:SSL certificate problem: self signed certificate in certificate chain
Administrator@liag MINGW64 /d/code
$ git clone https://user:[email protected]
Cloning into '9x40'...
fatal: unable to access 'https://xxxxxx.git':
SSL certificate problem: self signed certificate in certificate chain
解决方法:执行git config --global http.sslVerify false
关闭SSL认证;