Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
650 views
in Technique[技术] by (71.8m points)

git - 如何忽略有关本地更改的“ git pull”错误,因为合并会覆盖我的本地更改?(How do I ignore an error on 'git pull' about my local changes would be overwritten by merge?)

How do I ignore the following error message on Git pull?

(如何忽略有关Git pull的以下错误消息?)

Your local changes to the following files would be overwritten by merge

(您对以下文件的本地更改将被合并覆盖)

What if I want to overwrite them?

(如果我覆盖它们怎么办?)

I've tried things like git pull -f , but nothing works.

(我已经尝试过git pull -f类的东西,但是没有任何效果。)

To be clear, I only want to overwrite specific changes, not everything.

(需要明确的是,我只想覆盖特定的更改,而不是所有内容。)

  ask by mae translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want remove all local changes from your working copy, simply stash them:

(如果要从工作副本中删除所有本地更改,只需将它们存储起来:)

git stash save --keep-index

If you don't need them anymore, you now can drop that stash:

(如果您不再需要它们,现在可以删除该存储:)

git stash drop

If you want to overwrite only specific parts of your local changes, there are two possibilities:

(如果只想覆盖本地更改的特定部分,则有两种可能性:)

  1. Commit everything you don't want to overwrite and use the method above for the rest.

    (提交所有您不想覆盖的内容,其余使用上面的方法。)

  2. Use git checkout path/to/file/to/revert for the changes you wish to overwrite.

    (使用git checkout path/to/file/to/revert来覆盖您想要覆盖的更改。)

    Make sure that file is not staged via git reset HEAD path/to/file/to/revert .

    (确保未通过git reset HEAD path/to/file/to/revert 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...