github命令行_github命令学习笔记

更新时间:2019-06-02    来源:中文酷站    手机版     字体:

【www.bbyears.com--中文酷站】


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 //查看提交修改记录

本文来源:http://www.bbyears.com/kuzhan/52762.html

热门标签

更多>>

本类排行