如何从备份中取回我的更改?

发布于 2024-12-25 17:46:22 字数 649 浏览 0 评论 0原文

我的 Mac 遇到问题,决定格式化并重新安装所有内容。我将我的项目复制到其他机器上,希望 git 能够保留我的更改。现在我将我的项目复制回来,结果是我的所有文件都显示为复制粘贴的修改后的产品,是的,这是一个愚蠢的错误。

我怎样才能忽略所有这些虚拟差异并保留旧的更改? 有没有一个命令可以恢复所有这些差异?

谢谢

编辑: 对于“虚拟更改”,我指的是:

$ git diff --stat
 AuthenticationViewElements/background.png          |  Bin 6130 -> 6130 bytes
 AuthenticationViewElements/background_iPhone.png   |  Bin 5799 -> 5799 bytes
...
$ git diff AuthenticationViewElements/background.png 
diff --git a/AuthenticationViewElements/background.png b/AuthenticationViewElements/background.png
old mode 100644
new mode 100755

这里的更改是由文件副本引起的文件权限。这就是我想要摆脱的变化。

I was having problems with my Mac and decide to format and reinstall everything. I make a copy of my projects to other machine hoping that git will preserve my changes. Now I copy my projects back and the result is that all my files appears as modified product of the copy-paste, yes a fool error.

How can I ignore all this dummy differences and keep the old changes?
Is there a command that can revert all this differences?

Thanks

Edit:
With "dummy changes" I'm referring to this:

$ git diff --stat
 AuthenticationViewElements/background.png          |  Bin 6130 -> 6130 bytes
 AuthenticationViewElements/background_iPhone.png   |  Bin 5799 -> 5799 bytes
...
$ git diff AuthenticationViewElements/background.png 
diff --git a/AuthenticationViewElements/background.png b/AuthenticationViewElements/background.png
old mode 100644
new mode 100755

Here the change is in the file permissions caused for the copy of the file. This is the kind of changes I want to get rid.

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

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

发布评论

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

评论(2

罪#恶を代价 2025-01-01 17:46:22

如果还有 .git 文件夹,则应该保留所有版本的记录。我想也许你可以使用 git log 来找出你是哪个版本,git status 来了解这个存储库的状态,git diff (branch|Tag |HEAD) 来检查与其他人的差异。最后使用 git revert HEAD 恢复提交状态或使用 git checkout 签出提交。我建议使用像 Github 这样的服务来推送你的代码。

If there is still a .git folder, it should keep all version's record. I think maybe you can use git log to find out which version you are, git status to know what's the status for this repository, git diff (branch|Tag|HEAD) to check the differences from others. And finally use git revert HEAD to revert the commit status or git checkout to checkout the commit. And I recommend to use some service like Github to push your code.

山有枢 2025-01-01 17:46:22

看起来唯一的区别在于文件权限。您应该能够使用

git reset --hard

You might need to sudo that 清除它们。

Looks like the only differences are with the file permissions. You should be able to clear them with

git reset --hard

You might need to sudo that.

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