美文网首页Git
Git force pull

Git force pull

作者: JaedenKil | 来源:发表于2020-05-07 16:43 被阅读0次

Setting the local branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master
// Or if I want to make the local branch 'dev' to look exactly like remote 'origin/dev'
// First checkout to dev, then 'git reset --hard origin/dev'

But this reset will discard the local changes, in order to backup the local changes, before do reset:

git add xxx //add local changes
git commit -m "Backup local changes"
git checkout myLocalChangesBackup
// So the local changes will be stored in the new branch `myLocalChangesBackup` for backup

相关文章

网友评论

    本文标题:Git force pull

    本文链接:https://www.haomeiwen.com/subject/puvaghtx.html