Ignore specific files when pulling from forked upstream origin

感情迁移 提交于 2019-12-03 15:53:36

Yes you can do that.

git pull is shorthand for git fetch followed by git merge FETCH_HEAD

So first you can do a,

git fetch upstream

followed by,

git merge --no-log --no-ff --no-commit upstream/branch

Git will stop before committing. So, you should be able to modify the merge, and exclude the required files.

UPDATE

The commands can be combined using git alias.

Create an alias inside ~/.gitconfig

[alias]
   fnm = !git fetch upstream && git merge --no-log --no-ff --no-commit upstream/branch

You can further add,

[alias]
   fnm = !git fetch upstream && git merge --no-log --no-ff --no-commit upstream/branch && git reset file/path/not/to/be/updated && git checkout file/path/not/to/be/updated

Use git fnm for the complete operation.

However, this feels hacky

A less hacky way could be to avoid keeping a forked version of the file while wanting its updates. I don't know what your changes are, but what about proposing a merge request with your modifications?

If your modifications are rather personal (eg: local urls), what about proposing a merge request where you introduce a local configuration file?

That's what is done for example with https://github.com/fabelier/Doorbell: it provides a config.js.template file which is used by default, but the users can provide a config.js file to add their own specificities ; and this file isn't kept in Git.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!