git 用法记录,方便以后

1,$git status

查看分支状态


2,$ git add .gitignore
fatal: pathspec '.gitignore' did not match any files

$git add . 添加所有

添加到本地仓库


3,$ git commit -m "20170908"
[master (root-commit) 70642cf] 20170908

提交本地并添加相关信息


4,$ git checkout -b harry
Switched to a new branch 'harry'

切换到其他分支


5,$ git pull

远程仓库代码拉下来


6,$ git push origin master

提交到远程服务端


7,$ git log
commit 047c868f052fe450da6e38709520c80026b1598c

Author: nith.hou <nith.hou@t**.com.cn>

Date:   Tue Sep 5 11:25:41 2017 +0800

查看log信息


8,$ git reset --hard 3c936aee7b3e00f0086434f7e3bdbb43e54995e5
这个命令是恢复到对应版本

穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。

要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。


9,查看远程分支

使用如下命令可以查看远程仓库(我这里有一个origin仓库)

$ git remote -v

origin  git@github.com:username/Animations.git (fetch)

origin  git@github.com:username/Animations.git (push)


10,fetch更新本地仓库:

$ git fetch origin master:temp //从远程的origin仓库的master分支下载到本地并新建一个分支temp

$ git diff temp//比较master分支和temp分支的不同

$ git merge temp//合并temp分支到master分支

$ git branch -d temp//删除temp

11,$git revert c011eb3c20ba6fb38cc94fe5a8dda366a3990c61
revert 使用,需要先找到你想回滚版本唯一的commit标识代码

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值