cirosantilli / cirosantilli.github.io

Source for: https://cirosantilli.com and https://ourbigbook.com/cirosantilli Build HTML with https://github.com/ourbigbook/ourbigbook with "npm install && npx ourbigbook ." You can use this issue tracker for anything you want to tell me, even if it is not related to the repo. I also use this repo as generic issue tracker for myself.
https://cirosantilli.com
Creative Commons Attribution Share Alike 4.0 International
42 stars 9 forks source link

Is it possible to create new commits and push back changes after a git clone --filter partial clone? #50

Open yingxiaoGuo opened 4 years ago

yingxiaoGuo commented 4 years ago

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!

cirosantilli commented 4 years ago

(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.