Git 使用总结-常用命令 (一)

Git 常用命令

Git 图解

《Git 使用总结-常用命令 (一)》

1 Workspace: 工作区
2 Index/Stage:暂存区
3 Repository:仓库区(或本地仓库)
4 Remote:远程仓库

//初始化代码仓库
$ git init

//添加当前文件夹下所有文件 
$ git add .

//提交代码
$ git commit -m '修改信息'

// 将远程代码拷贝到本地
$ git clone [远程库地址]

// 关联远程仓库
$ git remote add origin [远程库地址]

// 查看本地分支
$ git branch

// 分支创建并切换到该分支
$ git checkout -b [分支名] 
实例 :git checkout -b Dev 

// 分支创建并切换到该分支 同步本地分支到远程分支 ,确保远程分支有该分支名
$ git checkout -b origin/[远程分支名]

// 删除 本地分支  注意不要在该分支上操作,切换到其他分支操作
$ git branch -D [本地分支名]

// 将本地分支删除后 同步
git push --delete origin [本地分支名]

//提交记录查看
$ git log

//回退到某个版本号 版本号可以通过'版本记录' 查看 
$ git reset --hard [版本号名称]

/************************组件化中Git常用*****************************/
// 组件快速创建
$ pod lib create [组件名]

// 本地验证 
$ pod lib lint 

// 本地验证  忽略警告
$ pod lib lint --allow-warnings

// 远程验证
$ pod spec lint

// 远程验证 忽略警告
$ pod spec lint --allow-warnings

// 查看本地索引库
$ pod repo

// 向本地端提交索引库 也就是把.spec 提交到本地创建的索引库中
$ pod  repo  push [本地索引库名称] xxxx.spec
// 忽略警告
$ pod  repo  push [本地索引库名称] xxxx.spec --allow-warnings

// 移除本地索引库
$ pod repo remove [本地索引库名称]

// 移除cocopod 索引文件
$ rm ~/Library/Caches/CocoaPods/search_index.json

// 打tag
$ git tag -a '版本号' -m '描述信息'

// 推送tag
git push --tags
    原文作者:git
    原文地址: https://segmentfault.com/a/1190000017828678
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞