Git - moving commits from one project to another using patches

Do this in the source project (you want to move):


git format-patch
<hash_fist_commit> HEAD -o <folder_where_all_pathces_will_be_saved>


Do this in the destination project (which you want new changes should appear):

<folder_where_new_changes_should_appear> -->

     -->  it can be the folder with another project in the monorepo project structure

git am --directory=<folder_where_new_changes_should_appear> --commit <folder_with_patches>/<patch_file.patch>


Attention:
If you had errors like file still in index or file still in working tree

your steps are:

  1. git rm --cached <file_name>
  2. rm <file_name>


P.S.: before doing any manipulations like I described, you should make a back_up_copy of your repository. Author doesn't take any responsibility for your repo damage. Happy coding🤗

Comments

Popular posts from this blog

Открываем порт для сервера Minecraft на роутере mikrotik (команда для терминала в WinBox)

Интересное о Формальдегиде