如何从备份中取回我的更改?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果还有 .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 usegit revert HEAD
to revert the commit status orgit checkout
to checkout the commit. And I recommend to use some service like Github to push your code.看起来唯一的区别在于文件权限。您应该能够使用
You might need to sudo that 清除它们。
Looks like the only differences are with the file permissions. You should be able to clear them with
You might need to sudo that.