将本地Git存储库与远程存储库同步 [英] Synchronizing a local Git repository with a remote one

查看:105
本文介绍了将本地Git存储库与远程存储库同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的本地存储库与远程存储库进行同步,以使我的本地存储库成为远程存储库的100%副本-这意味着,如果这些存储库中的某些文件不同,我们将用远程存储库覆盖本地文件,并如果本地存储库中的文件在远程服务器中不存在,则将删除本地文件.

I want to synchronize my local repository with a remote one so that my local repository becomes a 100% copy of the remote one - meaning that if certain files differ in these repositories, we override the local ones with the remote ones, and if there are files in local repositories that do not exist in the remote, the local files get removed.

除了进行远程存储库的全新克隆之外,还有其他方法可以实现此目标吗?

Is there any way to achieve that other than by doing a fresh clone of remote repository?

类似的问题,例如一口气将本地git repo与远程同步,放弃本地更改/提交.

推荐答案

git fetch --prune

-p, --prune
提取后,删除所有不再存在于远程上的远程跟踪分支. 修剪选项

-p, --prune
After fetching, remove any remote-tracking branches which no longer exist on the remote. prune options

这篇关于将本地Git存储库与远程存储库同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆