Git是分布式版本控制增删改
安装完成后,配置标识——用户名和邮箱
git config --global user.name “mingzi”
git config --global user.email “111111112qq.com”
创建版本库:
进入某一个位置新建文件夹
cd d:
cd www
mkdir test //创建test文件夹
cd test
pwd //查看当前位置
命令 git init 把这个目录变成git可以管理的仓库
对已有的文件me.txt进行操作:
git add me.txt添加到暂存区
git commit -m "提交时的注释"将文件提交到仓库
git status 查看是否还有文件未提交
git diff readme.txt 文件到底改了什么
git log 查看下历史记录
git log –pretty=oneline 信息太多时
版本回退
git reset --hard HEAD^ 当前的版本回退到上一个版本
HEAD^^ 回退到上上个版本
git reset --hard HEAD~100 回退到前100个版本
cat readme.txt查看内容
恢复版本号回退
git reflog ;获取到版本号
git reset --hard 版本号 ; 来恢复
git reset --hard 6fcfc89
Git撤销修改和删除文件操作
git checkout --readme.txt 撤销修改就回到添加暂存区后的状态
命令git checkout – readme.txt 中的 – 很重要,如果没有 – 的话,那么命令变成创建分支
rm b.txt当前目录下
如果我想彻底从版本库中删掉了此文件的话,可以再执行commit命令 提交掉
只要没有commit之前想在版本库中恢复此文件
git checkout – b.txt
Administrator@USER-20170216VK MINGW64 ~
$ cd d:
Administrator@USER-20170216VK MINGW64 /d
$ cd www
Administrator@USER-20170216VK MINGW64 /d/www (master)
$ git remoye add origin https://gitee.com/wang_li_rong/testgit.git
git: 'remoye' is not a git command. See 'git --help'.
The most similar command is
remote
Administrator@USER-20170216VK MINGW64 /d/www (master)
$ git remote add origin https://gitee.com/wang_li_rong/testgit.git
Administrator@USER-20170216VK MINGW64 /d/www (master)
$ git push -u origin master
remote: Incorrect username or password ( access token )
fatal: Authentication failed for 'https://gitee.com/wang_li_rong/testgit.git/'
Administrator@USER-20170216VK MINGW64 /d/www (master)
$