check whether exist a version of git
sudo apt-get install git
install by homebrew
After installed, run in terminal:#
$git config --global user.name "Your name"
To create a store#
init the git store
To wirite a file#
git is a version control system.
git is free software.
Then submit to git#
$git add "file name"
$git commit -m "write what you want to record"
Backup to the previous version#
back to last version of the workspace
$git log // show the log
$git reset --hard HEAD^ // reset to the last verson of the workspace
back to old one besides last version
$git log // to view id of last log
example :the old version id is xxxxxxxxxxxxx
you can use the command to back to that version
$git reset --hard xxxx(can use several previous number of the id )
- After you use the back command above, you also want to back again.
$git relog //this command to log the command you have code(only the present terminal window is not closed.)
find the id of the old persion you want to back up, then use the command with id to back up.
$git reset --hard xxxx(the id )
When you want to abort the file in workspace#
use the command
$git checkout --"file name"
$git status //view the status of workspace
only you don’t submit to git store using the command “git commit -m “what you want to record”, can you abort the changes.
Delete the file#
When you delete the file in file manager or delete file in terminal,then you want to delete them forever.
$git rm "file name"
$git commit -m "remove 'file name'" //delete the file in git store
Second situation, you just delete by mistake/accident, you can restore from git version store.
$git checkout --"file name" //use the abort command.