Let’s say I want to move dir_to_move from src_repo to the branch
br_target
in dest_repo.# clone a source repository
git clone url/to/src_repo src_repo
cd src_repo/
git remote remove origin
# filter the subfolder dir_to_move
git filter-branch --subdirectory-filter dir_to_move -- --all
mkdir dir_to_move
mv * dir_to_move/
git add .
git status
git commit -m "move dir_to_move to another repository" -a
git status
# clone a destination repository
git clone url/to/dest_repo dest_repo
# go to destination repository
cd ../dest_repo
# add a remote repository to the source repository
git remote add remote_src_repo ../src_repo/
# switch to branch target
git checkout br_target
# pull from remote source repository
git pull remote_src_repo master
# remove remote repository
git remote remove remote_src_repo
# remove temporary source repository
rm ../src_repo
No comments :
Post a Comment