Git 操作命令学习

windos平台

1.安装GitHub;

  下载GitHub 链接: https://pan.baidu.com/s/1qXCW4MS 密码: 2qpk;

  运行git-bash.exe;

2. 设置用户名;邮箱;

  $git config --global user.name "yourName"

  $git config --global user.email "your@email"

3. 创建版本库repositoty所在文件夹;

  mkdir Repository;

4. 初始化版本库;在此文件夹下执行;

  $git init;


5. 将文件添加到版本库;

  1. $git add some.file    将some.file 添加大暂存区stage;

  2.  $git commit  -m "注释要提交内容的说明"      提交到版本库;

6.查看版本库状态;

  $git status

7. 查看修改内容;

  $git diff

8. 查看修改日志;

  $git log

  $git log --pretty==oneline  查看单行日志;  


9、 版本回退; Head表示当前版本;

  $git reset  --hard HEAD^   回退上一个版本;

  $git reset --hard HEAD^^   回退上上个版本;

  $git reset --hard HEAD~50  回退50个版本;  

  $git reset --hard 版本号  去 commit_id 版本号 处;

  


10. 记录历史命令;

  $git reflog


    

 


11. 舍弃工作区的修改;

    让这个文件回到最近一次git commitgit add时的状态。

  $git checkout --file

  $git checkout 切换分支;

12. 将暂存区  的文件放回  工作区;

  $git reset HEAD file


 

13. 从版本库删除文件;

  1. $git rm    删除;

  2.  $git commit   并提交;  

 

 

 

 

 

      

posted @ 2017-12-22 22:46  web男  阅读(170)  评论(0编辑  收藏  举报