The following sequence is almost identical for creating as well as updating a vendor.
git switch [--orphan=]<vendor branch>
# if you used the orphan option tro create the branch, you will notice that at this point your project directory is now empty
# only for the first commit
git commit --allow-empty -m "create vendor XXX"
git subtree add (when creating) / pull (when updating) --prefix=<path to vendor dir> <vendor URL> <vendor Git ref>
Note that git subtree does not remember the vendor information, so that must be recorded in the upcoming VENDOR file. Also, '.' cannot be used as prefix.
Note about git subtree --squash:
cd <vendor dir>
git ls-files -z | xargs -0 rm -f
tar -xzf vendor.tgz
git add -A
# only if you didn't use `git subtree`:
git commit -m "import vendor XXX version YYY"
# tag
git tag <vendor tag> <vendor branch>
git switch taskbranch
This is where merging can become ugly.
git merge --allow-unrelated-histories --no-ff <vendor tag>
--allow-unrelated-histories otherwise first vendor merge won't work.
Use the vendor tag. It makes the vendor drop explicit.
Notice how the log shows how the orphan branch rejoined the main branch. This can best be seen in the network page of the GitLab fork.
edit VENDOR.md
Remember to mention at the very least the vendor URL
Often, a script will better suit the future developer that will have to perform a new vendor drop. You can find an actual Git example in the GitLab fork on this page.
hack away
switch main
merge task branch
Disclaimer: Personally I have never used them, and the Internet is not recomforting. But they do deserve a study.
Submodules are a bit hairy to deal with; the concept feels heavy.
To expand further.
Git tips (TO CONFIRM and maybe to move out of this file):
git rev-parse --show-toplevel[Dd]esktop.ini pattern does belongs in ~/.gitignore git config --get-all --show-origin core.whitespace
# optionally:
git config --global core.whitespace trailing-space,-space-before-tab,indent-with-non-tab,cr-at-eol
git help hooksTODO: replace with .gitattributes ?
git config --get-all --show-origin core.autocrlf # empty == 'false'
git config --get-all --show-origin core.safecrlf # empty == 'false'
git config --get-all --show-origin core.eol # empty = 'native'
$ git config --global core.autocrlf true
git config --global core.autocrlf input
See also
git help configsubdir option deal with large vendors?git subtree:
git help git-rm for details. Do notice BTW that the concept is mentioned in Git.https://sfconservancy.org/GiveUpGitHub/ https://giveupgithub.org/ https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguish