git 常用命令

官方git教程网址

https://git-scm.com/book/zh

一、GIT版本回退到某个版本并提交到远程仓库
1、查看当前分支的历史版本

git log --pretty=oneline

2、回退到分支的某个版本

git reset --hard 0762c500bb976c5884916dfd5f745e64d80f18ef

3、查看分支当前版本

git rev-parse HEAD

4、提交回退的版本到远程仓库

git push -f

5、撤销刚刚的commit了,查看status可以核实

git reset --soft 

二、git log 查看提交记录
1、显示被修改文件的修改统计信息,添加或删除了多少行。

git log --stat commit_id

2,显示最近两条的修改

git log --stat -2

3,显示具体的修改

git log -p -2

4,显示我自己的修改

git log --stat --author=wangkongming

5,查看单个文件最近两次修改的记录

git log --stat -2 -- ./classes/api/controller/mobile_communityController.php

三、git branch使用
1、查看本地分支

git branch

2、查看远程分支

git branch -r

3、查看所有分支

git branch -a

三、码云的git使用
1、git下载自己项目到本地:

     git init
     
     git pull https://github.com/TTyb/54qjLogin   (远程仓库url)

下载的这个项目更改后需要push的会出现

$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
 
    git remote add <name> <url>
 
and then push using the remote name
 
    git push <name>

2、git remote用法

这个时候第一次push需要网址:
 
$ git add --all
$ git commit -m "提交信息"
$ git remote add origin '远程仓库url'
$ git push -u origin 对应远程分支名
 
 
 
然后下一次就不用那么麻烦了,直接:
 
$ git add --all
$ git commit -m "信息"
$ git push
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值