Common operations of Git
Commit code
1  | git add .  | 
How to revoke after commit
1  | git reset --soft HEAD^  | 
This successfully revoked the commit. Note that only the commit operation is withdrawn, and the code modification remains.
git reset parameters
--mixed
do not delete the workspace to change the code, cancel the commit, and cancel the git add . operation. This is the default parameter.
--soft
do not delete the workspace to change the code, cancel the commit, and do not cancel the git add ..
--hard
delete workspace change code, revoke commit, revoke git add .. After completing this operation, it is restored to the last commit state.
How to migrate a git repository to another remote location
Method 1
1  | git remote set-url origin remote_git_address  | 
This method will only migrate the current branch to the new git.
In addition, this method could meet errors and fail, such as “error: source ref specification master does not match”.
Method 2 (better)
1  | git push --mirror remote_git_address  | 
This method only need one command to finish this job.
How to save username and password of git in Ubuntu
1  | nano ~/.gitconfig  | 
Edit the config file and set this config:
1  | [credential]  |