Is it possible to create new commits and push back changes after a git clone --filter partial clone?
yingxiaoGuo opened this issue · 1 comments
Hi! I am here for a StackOverflow question.
Where you give the answer about cloning a subdirectory only of a Git repository:
git clone \
--depth 1 \
--filter=combine:blob:none+tree:0 \
--no-checkout \
"file://$(pwd)/server_repo" \
local_repo \
;
cd local_repo
git checkout master -- mydir/
That is really useful! But I am wondering if I could further update the cloned subdirectory and it is possible to pull another branch from the remote.
Thanks in advance for your reply!
(this is a followup to: https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934 )
Hi Yingxia,
In theory both of hose should be possible.
All git needs to create the new objects are the old commit object, and the directories leading to the blob.
The a git push only pushes the new objects.
You can familiarize yourself further with the format of Git objects at: https://stackoverflow.com/questions/22968856/what-is-the-file-format-of-a-git-commit-object-data-structure/37438460#37438460
Branches should also work in theory. In theory, you can request only whatever objects you need from remote to reach to reach a given local state.
Of course, if this will be actually done on those early implementations, I don't know.