Search code examples
gitgithub

How is it best to update a project when updates are provided as an archive?


During the project, we encountered an issue with updates being delivered as an archive while work on the project is ongoing simultaneously. We are planning to improve the update process using patches, but there are concerns about potential conflicts between the changes in the project and the updates from the archive.

For example, there is a task to migrate the models to S3. The migration has been done, but an update was delivered, and now we need to compare again. Is it correct to assume that a git patch is the best solution for this?

  1. Through git pre-merge, there was a hook that collected changes using markers:

NO_CHANGE_START

NO_CHANGE_END

If changes occurred within these markers, a conflict would be raised, but there was still a lot of manual work involved.

  1. We have now switched to patches, but sometimes a line doesn't match exactly, which can occasionally lead to even more conflicts.

Solution

  • You can make a commit from the exact contents of an external archive easily, unpack it and

    git --work-tree=/path/to/unpacked/archive add .  # with `-f` to bypass local ignores
    git commit
    

    and from there any format you want is easy, it's a commit. Check out whatever the archive was based on first, give the correct --author and --date attributions to git commit, and you've now got an accurate Git history to work with. The local work tree will need some cleanup if you're going to work on that commit, git reset --hard; git clean -dfx is my usual clean-slate wipe.