节选自:
git是一个分布式的引擎,相当于在本地有一个服务器,你先把你的改动commit到本地的,
然后再push到主服务器上。 同时如果你想要更新,则需要先在本地commit,然后再去pull.创建仓库
mkdir learngit git init 添加文件到git仓库 cd learngit echo "git is a version control system, and it is created by Linux , it is free software" >>ReadMe.txt git add ReadMe.txt 提交到本地服务器: git commit -m "wrote a readme file" 查看当前的状态,仓库里的文件是否有被修改过? git status 查看文件的具体改动: git diff ReadMe.txt 提交变更的文件和提交新文件是一样的,也是需要两步, 一步是git add ReadMe.txt 第二步是 git commit -m "update Readme.txt 's content"git log 查看提交的日志记录
回到历史版本: HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。 穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。 要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。