Scenario 1: When you mess up the contents of a file in your workspace and want to discard the workspace changes directly, use the command git checkout -- file .
Scenario 2: When you not only changed the contents of a file in the workspace, but also added to the staging area, want to discard the changes, two steps, the first step with the command git reset HEAD file , back to Scene 1, the second step by scene 1 operation.
Scenario 3: When an inappropriate modification to the repository has been submitted, you want to revoke this commit, refer to the version fallback section, but only if it is not pushed to the remote library.
Command git rm to delete a file. If a file has been submitted to the repository, then you never have to worry about accidentally deleting it, but be careful that you can only recover files to the latest version and you will lose what you modified after the last commit .
To associate a remote library, use the command git remote add origin [email protected]:path/repo-name.git ;
Once associated, use the command to git push -u origin master push all the contents of the master branch for the first time;
Thereafter, after each local submission, whenever necessary, you can use the command to git push origin master push the latest changes;