![](/img/trans.png)
[英]Push the updated master branch to remote repository which in in same project folder and configured in local git repo
[英]Can someone tell me how I can get the master branch on my local repo to reflect the master branch on the remote repo?
您可以使用git log
显示提交列表,然后只需使用提交 hash 重置HEAD
git log
/* Shows list of commits */
git reset b10a4d7
示例 git 日志
* 46a3ae9 (HEAD -> main) Fix JS syntax error
* faeed22 Do thing
* b10a4d7 (origin/main, origin/HEAD) Linting
* 7cb8974 Fix bugs
使用的 hash 是指向origin/main
或origin/master
的那个
如果当前分支是master
( HEAD
指向master
),则将当前分支移动到与远程跟踪分支origin/master
相同的提交:
git reset --hard origin/master
如果当前分支不是master
分支——首先结帐然后移动:
git checkout master
git reset --hard origin/master
另一种变体:首先移动非当前分支然后结帐:
git branch --force master origin/master
git checkout master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.