[英]How to pull the branch of remote repo to cover the changes in the local repo
Git Structure: Git结构:
1. Local repo:
(1) main
(2) test_branch
2. Remote repo:
(1) main
(2) test_branch
For some reasons, some contents in test_branch in the local repo are messed up, so I want to pull the test_branch in the remote repo to the test_branch in the local repo to recover the original structure.由于某些原因,本地repo中test_branch中的一些内容乱了,所以想把远程repo中的test_branch拉到本地repo中的test_branch中,恢复原来的结构。
Tried:尝试:
git checkout test_branch
git pull origin test_branch
But it didn't work.但它没有用。
Also dig other threads :还挖掘其他线程:
Git: How do I force "git pull" to overwrite local files? Git:如何强制“git pull”覆盖本地文件?
Tried:尝试:
git fetch --all
git branch backup-test_branch
git reset --hard origin/test_branch
But it also didn't work.但它也没有奏效。
Any suggestions are appreciated.任何建议表示赞赏。
You can always delete your local branch and recover from the remote, try the following:您可以随时删除本地分支并从远程恢复,请尝试以下操作:
git checkout main
git branch -D test_branch
git checkout test_branch
To explain what it's doing, it is changing the current branch to main
, deleting the local copy of the test_branch
and then changing back to the test_branch
branch, but now synchronized with the remote one.为了解释它在做什么,它将当前分支更改为
main
,删除test_branch
的本地副本,然后更改回test_branch
分支,但现在与远程分支同步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.