指引网

当前位置: 主页 > 操作系统 > Linux >

github命令学习笔记

来源:网络 作者:佚名 点击: 时间:2017-05-13 00:16
[摘要]  下面给大家整理了一些常用的github命令了,在这里是我在学习时学到了与整理了其它站长朋友学习时的笔记了,有兴趣的朋友可参考一下。


1、创建版本库

mkdir test

git init

2、提交代码

git add test.php

git commit -m "this is a comment

3、查看状态

git status

4、与版本库比较文件差异

git diff HEAD – - test.php

5、查看日志

git log

git log – -pertty=oneline

6、退回上一个版本

git reset – -hard HEAD^  (HEAD^^ 上上一个版本,HEAD~100 上100个版本)

7、退回指定一个版本

git reset – -hard id号 (reflog查看版本id号)

8、查看文件内容

cat test.php

9、删除文件

rm test.php

10、撤销修改

git checkout – - test.php

11、创建SSH KEY

ssh-keygen -t rsa -C "你邮箱地址"

12、连接远程库

git remote add testname git@github.com:testuser/test.git

13、把项目推送到远程库

git push -u testname master

14、克隆项目到本地

git clone git@github.com:testuser/test.git

git remote add upstream https://github.com/winterIce/testTitle.git(别人的repository)    // 新建分支用于存放别人的repository

git clone https://github.com/winterIce/testTitle.git  克隆到本地

git fetch branch2//更新信息

git merge branch2/master    //merge本地信息

git add . //添加新文件或者更改新文件

git remove  ** //删除文件

git commit -m 'by who do what'  //提交文件到本地

git push  push到服务器上

git pull origin master 从服务器上拉取信息

git remote  查看repository上的所有分支

git branch -a  查看所有分支

git branch -r 查看远程分支

git branch -d *** //删除分支

git branch *** //新建分支

git checkout ***//切换分支

git status //查看状态

git log //查看提交修改记录

------分隔线----------------------------
栏目列表
推荐内容