The best way to handle this, if upstream does not use git, is to manually replicate that functionality using something called a vendor branch (the actual name of the branch doesn't matter, I will call it "upstream" here, but when doing searches, I believe vendor branch is the term of the art).
This is best done BEFORE making any local modifications, so that git will be able to track what is going on. If you can rewrite history (force push, making everyone else essentially reclone or rebase) then you can kinda do it after (there are some even more tricky ways of doing it, which I don't recommend).
The way to do this is:
- Create the new directory and unpack your vendor's source code into it
git init
to create the git repository
git add -Af .
(assuming that this is a true fresh unpack without any unwanted files in it)
git commit -m "Some text describing where you got the source code, how the vendor identified it, etc"
git branch -m master upstream
will name the fresh new commit to master
- At this stage, you modify the master branch to do what you want
At some later point, vendor makes a new release. You then.
git status
and git stash -a
and friends to make sure everything (tracked, untracked, whatever) is committed , stashed, or can be deleted.
git checkout upstream
find . -maxdepth 1 -mindepth 1 ! -name .git -print0 | xargs -0 rm -f
Clean the directory of everything.
- Unpack the vendor code
git add -Af .; git commit -m "similar description as above"
will commit the vendor information
git checkout master; git merge upstream
will merge in the changes vendor made. You go through normal conflict resolution.
- Continue with your changes to the vendor package.
If you ever want to send a fix back to the vendor, make a new branch off of vendor to the patch, then merge that patch back into master. You can send the vendor that patch and if they pick it up all will be well and everything should work automatically. If they modify it, you will have to go through conflict resolution as normal. However, the key here is that the vendor branch itself should always remain pristine.
If you want to ignore binaries and only deal with configuration files, you can add the binaries to .gitignore before doing the vendor branch commits (and don't use -f to git add -A
).