1.initial your git
2.create your repository
3.reopen git blash——>find file
4.add and modify
5.Restore
all things will be executed in git bash
1. initiate it:
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
Here are some basic techniques
2.create your own repository
$ mkdir learngit
$ cd learngit
$ pwd
/Users/michael/learngit
git init
//here mkdir means create a new file
$ mkdir + 目录名 <直接创建>
$ mkdir + -p + 目录名/目录名 <递归创建>
3.Open the file you want
//if you have closed the black box but want to make some change in a particular filee.g.:if I wan to find *learngit*
$ cd ~
$ pwd
$ cd learngit ~
4.Add and modify——>commit
if you want to commit some your changes
$ git add readme.txt
$ git commit -m "make some change"
here :
add——add a file to to repository
m——comment of this commit
5.Restore
if you want to restore the version you have made before you cancheck the log
$ git log //haven't closed the balckbox before
//or
$ git log --pretty=oneline
//or
$ git reflog //already closed the blackbox
restore
$ git restet --hard HEAD^
//or
$ git reset --hard 49d25(based on log, just pick first few digits)
here :
^—the last version,you can also input ^^,but if you want to restore the file before 100