Forking a project and fetching updates without bringing in the previous history up until the initial commit

StackOverflow https://stackoverflow.com/questions/23176669

  •  06-07-2023
  •  | 
  •  

Question

So lets say I have repository A and I create repository B, which I intend to be a fork of A. I clone A and delete .git, then recreate it, add origin and push, thereby replacing the history with 1 commit. All is fine until project A updates a file. Since I want to keep up with A, I fetch and merge the changes into B. However, when I fetch the changes, it also fetches the entire past history, tags, branches, everything, which I don't want.

What I do want however is just the file history (like the commit that introduced the new change, and the actual file modifications) from master, or whichever branch I specify, without tags and branches, and without always bringing back folders I deleted.

If this isn't possible, is there a way to tell git to load the changes that instead of merging entirely, I can tell it which changes to apply and which to discard?

Was it helpful?

Solution

You should be able to use cherry-pick to do what you want: https://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top