以下是分支的命令
1.克隆远程仓库
git clone "https://---"
2. 上传到默认分支
git push
3.上传到指定分支
git push origin "分支名称"
4.下拉到默认分支
git pull
5.下拉到指定分支
git pull origin "分支名称"
6.查看当前分支
git branch
6.新建分支
git branch "分支名称" // 去掉""
7.切换得到某分支
git checkout "分支名称"
8.创建分支并且切换到分支
git checkout -b "分支名称"
9.删除分支
git branch -d "分支名称"
10.查看提交历史
git log
11.查看当前版本的改动
git status
12.合并分支
git checkout "当前分支"
git merge “需要合并的分支”
例子:如果 “bug分支” 合并到“master分支”
# 首先切换到master分支
git checkout master
# 然后合并到bug分支
git merge bug
# 删除分支
git branch -d bug
13.移除已经提交到仓库的文件
git rm -r --cached "文件名称" # git删除已经提交的文件夹当个文件
git reset HEAD~ #清理上次提交的commit 数据
14.查看最近一次提交
git show
15.查看某一次提交
git show 54edf323
16.创建一个tag
git tag "v1.0" #首先代码合并到master分支,然后创建tag标签
17.推送v1.0到远程仓库
git push origin "v1.0"
一个上传的流程
git pull origin "当前分支"
git add . 或着 git add "单独一个文件"。 #可以通过git status 查看当前的改动
git add commit -m "上传的说明"
git push origin "当前分支名称"
回滚到工作区的并忽略某文件
git log // 查看当前提交
git reset "commit-id" // 回滚到某一个提交记录
git status // 查看修改文件。 找到需要忽略的文件目录
"Untracked files:
(use "git add <file>..." to include in what will be committed)
libs/aaaa.framework/"
libs/aaaa.framework/ 添加到.gitignore 文件中
匹配 .gitignore 文件规则
清理缓存 如果某些文件在之前已经被Git 跟踪过,需要使用以下命令清除git的缓存。
git rm -r --cached .
git add .
git commit -m "apply .gitignore rule"