简体   繁体   English

Github 仓库与本地不同步

[英]Github repo out of sync with local

I have a master project stored on my development machine.我的开发机器上存储了一个主项目。 I push this to Github when changes are made.进行更改时,我会将其推送到 Github。

But, I made 2 changes directly on Github as they were only modifications to the README and I was on a different computer.但是,我直接在 Github 上进行了 2 次更改,因为它们只是对 README 的修改,而且我在另一台计算机上。

My local is now different to the remote (the Github repo).我的本地现在与远程(Github 存储库)不同。

How do I get the local back in sync?如何让本地恢复同步? The local was the main copy, but I think it's better to have the Github repo as the master.本地是主要副本,但我认为最好让 Github 存储库作为主副本。

You should run a git pull origin main and merge with your local.您应该运行git pull origin main并与您的本地合并。

When done merging do git push origin main to sync up the remote合并完成后,执行git push origin main以同步远程

If your local changes are too large you can use git stash to hide them temporarily and pop them out of the stash ( git stash pop ).如果您的本地更改太大,您可以使用git stash暂时隐藏它们并将它们从 stash ( git stash pop ) 中git stash pop


EDIT: October 2020: Github changed master to main .编辑:2020 年 10 月:Github 将master更改为main For older git repos please use master instead of main in above commands对于较旧的 git repos,请在上述命令中使用master而不是main

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM