I am a bit new to Git, I think I almost have the solution but there are some things I don't like about it.
I would like to change the README.md
file of a fork I follow very closely (just a few additional files that will most certainly NOT be merged upstream) so that users of my fork can have instructions for how to use my fork. To that end, I think I would like to pull from upstream while ignoring some files from upstream, such as README.md
. I would also like to automate this process as I will be pulling from upstream often, and upstream could potentially change the README.md
file a lot.
I've read this answer but I was not satisfied as it seems to introduce a useless merge commit.
Here is what I've come up with (untested):
# upstream remote might not be configured
UPSTREAM="https://github.com/someone/repo.git"
# .gitkeep has all the file globs I want to ignore from upstream
xargs -a .gitkeep -d'\n' git stash push
git fetch "$UPSTREAM" master
git merge --no-ff --no-commit -X theirs FETCH_HEAD
xargs -a .gitkeep -d'\n' git reset
git commit -m "Useless merge commit? :("
git stash pop
Is there a better way I can get what I want? Or can I somehow get rid of the useless merge commit?
Specifically, I would like to fork the void-packages repository, which contains build instructions for every package in the Void Linux package repositories, to add my own packages that cannot be accepted in the main repositories. I plan to use Github Actions to build the packages and distribute them, so I would like to add easily discoverable instructions on how users may add this custom package repository for themselves.
I don't want to use Nix because of #9145 (unless there is a nice way to start all GUI applications with NixGL), and I can't use Flatpak because not all of the software I want to use is available for Flatpak.
I realize my specific problem may seem a little bit stupid, but I still think it's good in general to be able to fork a project while "ignoring" some files from upstream without that useless merge commit.