在不覆盖数据的情况下进行git结账 [英] To git checkout without overwriting data

查看:132
本文介绍了在不覆盖数据的情况下进行git结账的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何在不覆盖数据的情况下 git-checkout

  git checkout master 

我得到

 错误:条目'forms / answer.php'将被合并覆盖。无法合并。 

这很令人惊讶,因为当我 git时我不知道Git会合并-checkout 。
我总是在命令之后单独运行 git merge new-feature
如果Git在结帐时合并,这看起来似乎没有必要。

Git正在警告你表单/答案。 php在您的工作副本或索引中没有提交的变化。



您可以使用 git-stash 以保存您的更改,然后 git-stash apply 将其恢复。



git-stash 的常见用例是您正在处理更改,但必须暂时检出其他分支以进行错误修复。因此,您可以将您的更改存入索引和工作副本,检出其他分支,进行错误修复,提交,签出原始分支,并 git-stash apply 以恢复您的更改并从您离开的地方取件。


How can you git-checkout without overwriting the data?

I run

 git checkout master

I get

error: Entry 'forms/answer.php' would be overwritten by merge. Cannot merge.

This is surprising, since I did not know that Git merges when I git-checkout. I have always run after the command separately git merge new-feature. This seems to be apparently unnecessary if Git merges at checkout.

解决方案

Git is warning you that forms/answers.php has changes in your working copy or index that have not been committed.

You can use git-stash to save your changes then git-stash apply to restore them.

The common use case of git-stash is that you are working on changes but then must temporarily checkout a different branch to make a bug fix. So you can stash your changes in your index and working copy, checkout the other branch, make the bug fix, commit, checkout the original branch, and git-stash apply to restore your changes and pick-up where you left off.

这篇关于在不覆盖数据的情况下进行git结账的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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