Files
knowledge-kit/Chapter7 - Geek Talk/7.3.md

68 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# git常见使用
```
http://blog.csdn.net/wirelessqa/article/details/20153689
```
1. git init
2. git add .
3. git commit -am "\#\#\#"
4. git remote add origin git@xx.xx.xx.xx:repos/xxx/xxx/xxx.git
5. git push origin 本地分支:远程分支
fatal: refusing to merge unrelated histories
决办法git pull origin main --allow-unrelated-histories
### 创建新版本
* 从现有的分支创建新分支
* git checkout -b dev
* 将新创建的分支提交到远端
* git push origin dev
* 提交代码
* git add .
* git commit -m 'add a new branch named dev'
* git pull origin dev
* git push origin dev
## Githubu 不允许上传超过 100MB 文件
关键点:
- git-lfs 添加允许上传的文件名称或者文件类型
- 如果按照顺序1-2-3-4-5-6-10-11-12 还是会存在上传不成功的情况,所以需要严格按照下面的顺序执行
```Shell
//1
git rm --cached -r video/Company-Website-Pro.mov
//2
git commit --amend
//3
git push
//4
brew install git-lfs
//5
git lfs install
//6
git lfs track "*.mov"
//7
git add .gitattributes
//8
git commit -m '.gitattributes'
//9
git push origin main
//10
git add /Users/liubinpeng/Desktop/Github/Company-Website-Pro/video/Company-Website-Pro.mov
//11
git commit -m 'video'
//12
git push origin main
```
## 代码回滚到某个 tag
- 先查看所有的 tag: `git tag`
- 查看需要回滚的 tag 对应的 commitid: `git show {tag号}`
- 回滚: `git reset --hard {commitId}`