我如何从我的“公众”中获取信息? git 服务器将我损坏的本地“master”带到最新?

发布于 2024-08-13 01:17:55 字数 148 浏览 1 评论 0原文

我有一个本地“主”git 存储库。每隔几个小时,我就会将更改“git Push”到服务器,然后从服务器拉取到客户端计算机。好吧,我不小心使用 GITK 将我的本地“主”存储库回滚了一个版本。

从服务器拉回最后提交的版本并且仍然让我的本地版本表现得“出色”的步骤是什么?

I have a local "master" git repository. Every few hours, I 'git push' my changes to a server from which I then pull to my client machines. Well, I accidentally used GITK to rollback my local "master" repository one version too far.

What are the steps to pull the last committed version back from the server and still have my local version behave "masterfully"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

囍笑 2024-08-20 01:17:55

假设您的本地 master 仍然是干净的,,没有本地更改,但服务器存储库上 master 后面有一些提交,您只需从中提取:

git pull server master

在上面的命令中,server< /code> 是其他客户端从中提取的远程名称(或者您可以使用其 URL)。

Assuming your local master is still clean, i.e., no local changes, but some number of commits behind master on the server repo, you need only pull from it:

git pull server master

In the above command, server is the name of the remote that other clients pull from (or you could use its URL instead).

樱花坊 2024-08-20 01:17:55

首先,存储现有的更改:

git stash

然后,运行(考虑到您要更新本地存储库的远程名称为 origin):

git remote update origin
git reset --hard origin/master

应用存储的更改:

git stash pop

First, stash your existing changes:

git stash

Then, run (considering that the remote from which you want to update your local repository to be named origin):

git remote update origin
git reset --hard origin/master

Apply the stashed changes:

git stash pop
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文