Reputation:
I have a repo (repoA) and a file in that repo has 20-30 commits; I want to move that file to repoB with all of the commit history; how do I do that?
Upvotes: 1
Views: 47
Reputation: 736
As I understand you want to move changes only from one file and save the history of all repository.
Commits in git aren't about some file. They are about repository.
Maybe you can do something like:
1)get file changes from repoA and copy them in repoB as new commit.
2)after some time push repoB into master for example
3)merge master with repoA. Resolve conflicts if any.
Upvotes: 0
Reputation: 30156
If what you want to move is the whole branch as it is, just add a new remote pointing to the new repo and push the branch to it. If you have 30 commits with say 50 files and you want to move the history of a "single" file, as if the file was always alone you will have to rewrite the history of the branch so that you get only the history of that file, no more and then you will add the remote and then push to it.
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
Upvotes: 2