git force coverage of local code (consistent with git remote repository)

[git] Force coverage of local code (consistent with git remote repository)
git forced coverage:
    git fetch --all
    git reset --hard origin/master
    git pull

 
Git forcibly overwrites local commands (single execution):
    git fetch --all && git reset --hard origin/master && git pull
 
The first one is: pull all updates, not synchronized;
the second one is: local code synchronization online The latest version (will overwrite all local files with the same name as the remote warehouse);
the third one is: update it again (in fact, it can be omitted, the second step command has been done)

Push to the remote branch
After executing git reset, the local has been rolled back to the specified version. If you need to push to the remote warehouse, you need to force the commit.

$ git push -u -f origin master
It is recommended to consider whether you need to back up the code before rolling back, otherwise it will be a tragedy!

View remote repository commit history

git branch -a #View all branches (including local and remote)
*master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master

git log remotes/origin/master #(origin/master This is the default remote warehouse and branch, you can change it to the warehouse and branch you want to see)
git log remotes/origin/develop

Of course, if your local has not updated the information of the remote warehouse for a long time, the logs you see may not be the latest;

So you need to run git fetch or git fetch origin before viewing.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324140069&siteId=291194637
Recommended