Posts

Showing posts with the label patch

Git patch workflow

  In the  Git , you can apply patches using the  git apply   command for changes from a   git diff   or   git am   for patches generated by   git format-patch . The method you choose depends on the patch's format and whether you want to create a new commit.   Before you apply a patch Back up your work.  Before applying a patch, you should have a clean working directory . Either commit or stash your uncommitted changes to avoid complications. Use a temporary branch.  It's a best practice to create a new, temporary branch to test the patch. If something goes wrong, you can simply delete the branch without affecting your main codebase. sh git checkout -b temp-patch-branch Use code with caution. Check the patch.  To see if the patch will apply cleanly, run a check with the  --check  flag. sh git apply --check my_patch.patch Use code with caution.   Method 1: Using  git apply Use this command for patches cre...

Git - moving commits from one project to another using patches

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: git rm --cached <file_name> 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🤗