1. 初始化仓库
创远程仓库
在项目中git init
关联远程仓库 git remote add origin 地址
git add .
git commit -m “内容”
更新项目,避免与远程仓库冲突
1
git pull --rebase origin master
git push origin mastererror: filename in tree entry contains backslash: '\'1
2
3
4
5
6
### 2. 反斜杠错误'\\'
git 2.24版本存在这样的问题,更新git项目中的子模块会报错,导致不成功,错误如下git config commit.template [模板文件名]1
2
3
4
5
6
7
8
9
10
11

**解决办法:**
- 升级git版本到2.25或者降到2.23都可解决此问题
- 禁用[core.protectNTFS](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&prev=search&rurl=translate.google.com&sl=en&sp=nmt4&u=https://git-scm.com/docs/git-config&xid=17259,15700022,15700186,15700190,15700259,15700271,15700302&usg=ALkJrhgI-ExxieOLS4BgBJejN9E-jIKJ3w#Documentation/git-config.txt-coreprotectNTFS) : `git config --global core.protectNTFS false`
### 3. 设置提交模板git checkout master1
2
3
4
5
6
### 4. 删除分支
先切到mastergit branch -a1
2
查看本地已有的和远端的所有分支git push origin --delete 分支名1
2
#### 4.1 删除远程分支git branch -d 分支名 //有可能会提示使用-D的命令 git branch -D 分支名1
2
#### 4.2 删除本地分支git remote show origin1
2
3
4
5
6
7
8
### 5. 远端分支已经删除,本地依旧能看到
1.使用git branch -a查看本地和远程分支,会发现有些已经在远程仓库删除的分支,本地依旧能看到
2.查看本地分支与远程分支的关系git remote prune origin1
2
3.删除远程仓库已经不存在的分支git rm -r --cached .1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### 6. TortoiseGit设置ssh方式
1.进入tortoise的设置界面-->点击 `Re-run First Start Wizard`

一直next(下一步),直到 Authentication an credential store界面,设置ssh为OpenSSH方式,完成

### 7. 已提交的项目添加.gitignore文件
1.清除本地项目缓存touch .gitignore1
2
2.新建.gitignore文件git add . git commit -m "add ignore"1
2
3.再次提交所有文件git push1
2
4.提交到远端git branch -m oldBranch newBranch1
2
3
4
5
6
### 8. 修改本地以及远程分支名称
1. 重命名本地分支git push --delete origin oldBranch1
2
2. 删除远端分支git push origin newBranch1
2
3. 将本地已重命名的分支推到远端git checkout newBranch1
2
4. 切换到新分支git branch --set-upstrean-to=origin/newBranch1
2
5. 关联本地和远端的分支1
2
3
4
5
6
7
8
9
10
11
### 9. tag操作
- 列出tag
```git
git tag -l
git tag -l "v1.1.1*" //筛选出v1.1.1开头的tag
git ls-remote -t //查看远端tags
- 创建tag
1 | git tag -a [tagName] -m '[注释]' |
- 推送tag到远端
1 | git push origin [tagName] |
删除tag
删除本地tag
1
git tag -d [tagName]
删除本地所有tag
1
2
3
4git tag -l|xargs git tag -d
//拉取远端所有tag
git fetch origin --prune删除远端tag
1
2
3
4//方式一
git push origin :refs/tags/[tagName]
//方式二
git push origin --delete [tagName]
10. SSL certificate problem
在clone 仓库的时候报:SSL certificate problem: unable to get local issuer certificate
大概就是 SSL证书过期导致的
解决办法:
直接关闭SSL证书校验
1 | git config --global http.sslVerify false |