Initialize the repository in an existing directory
First create an empty directory, enter this directory and use the git init command
git init
Clone an existing repository
Ordinary clone: git clone warehouse address
Custom local warehouse name: git clone warehouse address custom name
Edit and add files to repository
Add changed or newly added files to the changes waiting to be submitted, only one file can be added at a time
Add files normally: git add App.class
Add files forcefully: git add -f App.class
Commit the changes to the repository
Multiple files can be submitted at once
git commit -m "Description of this commit"
View the current status changes of the git repository
git status can see which files in the working directory have not been put into the temporary storage area and which contents of the temporary storage area have not been submitted to the warehouse
git status
Compare changes
Compare the content of a file before and after it has been modified
git diff file name and suffix
view log
View all commit records: git log
git log --pretty=oneline
View historical commit timeline: git lg
git rollback
Go back to the previous version: git reset --hard HEAD^
Go back to the previous version: git reset --hard HEAD^^
Go back to the last 50 versions: git reset --hard HEAD~50
git reset
Want to revert to a new version after going back to a certain version
First find the commit id of the new version: git reflog
switch version: git reset --hard commitid