![](/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.