以下是分支的命令
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.創(chuàng)建分支并且切換到分支
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.移除已經(jīng)提交到倉庫的文件
git rm -r --cached "文件名稱" # git刪除已經(jīng)提交的文件夾當個文件
git reset HEAD~ #清理上次提交的commit 數(shù)據(jù)
14.查看最近一次提交
git show
15.查看某一次提交
git show 54edf323
16.創(chuàng)建一個tag
git tag "v1.0" #首先代碼合并到master分支,然后創(chuàng)建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 "當前分支名稱"
回滾到工作區(qū)的并忽略某文件
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 文件規(guī)則
清理緩存 如果某些文件在之前已經(jīng)被Git 跟蹤過,需要使用以下命令清除git的緩存。
git rm -r --cached .
git add .
git commit -m "apply .gitignore rule"