Migrate Git History

[Solved] Migrate Git History | Shell - Code Explorer | yomemimo.com
Question : git migrate repository with history

Answered by : daljeet-singh

{"tags":[{"tag":"textarea","content":"#the best and simple solutions is this\n\n\n$ git clone --mirror https:\/\/url-of-the-source-git-repo.git\n\n$ cd to-your-git-repo-folder.git\n \n$ git remote set-url --push origin https:\/\/url-of-the-destination-git-repo.git\n\n$ git push --mirror","code_language":"shell"}]}

Source : https://datanextsolutions.com/blog/how-to-migrate-git-repository-with-branches-and-commit-history/ | Last Update : Tue, 23 May 23

Question : migrate git history

Answered by : hugo-fusinato

#Create your new repo
mkdir new-repo
#Clone the source repo
git clone https://github.com/johno/a-repo
#Filter all commits aside from the directory you care about in the source repo
git filter-branch --subdirectory-filter my-dir -- -- all
#**Add a "local remote" to the source repository"
git remote add source-repo ../a-repo
#Then fetch the "local remote"
git fetch source-repo
#Create a branch from the source's master
git branch source-repo remotes/source-repo/master
#Then merge in the source repo
git merge source-repo --allow-unrelated-histories
#Lastly, clean up the source repo
git remote rm source-repo
git branch -d source-repo
#And commit
git push origin master

Source : https://johno.com/move-directory-between-repos-with-git-history | Last Update : Fri, 05 Aug 22

Answers related to migrate git history

Code Explorer Popular Question For Shell