git常用操作

git可以简单的分为三个区域 
   1、工作区(working directory) 
   2、暂缓区(stage) 
   3、版本库(Repository)

git init	#初始化仓库

'''配置用户'''
git config --local user.name **
git config --local user.email **

git status	#查看git管理库

git log		#查看日志
git reflog    #查看每一次的commit id

git add 文件名		#添加文件到git管理库(stage状态)
git add .     #添加所有文件

git commit -m <msg>		#提交更改
git commit -amend --no-edit    #覆盖前面的提交

'''查看版本改动'''
git diff	#对比modified和staged
git diff --cached	#对比staged和上一次的commit
git diff HEAD -- <file> 	#(“--”前后有空格),查看工作区和版本库里面最新版本的区别。


'''版本回滚'''
git checkout	#撤销add
git reset <id前几位>	#移动HEAD指针
git reset --hard <id前几位>   #回滚版本(同时改变仓库和本地,后面的版本会丢失)
git revert	<id前几位>		#用一次新的commit来回滚之前的commit

'''分支管理'''
git branch		#查看分支
git branch <name>	#创建分支
git checkout <name>   #切换分支
git checkout -b <name>  #创建并切换分支
git merge <name>	#合并某分支到当前分支
git branch -d <name>	#删除分支

'''远程库管理'''
git remote	#查看远程库信息
git remote -v    #查看远程库的详细信息
git pull origin master	#将远程库的更新拉取到本地来
git push origin master	#把master分支推送到远程库对应的分支上

git clone --branch v0.9.5 --recursive https://github.com/apache/incubator-mxnet.git  #从github下载指定分支

git config --global credential.helper store		#解决每次都输入密码都问题

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值