'What is the best way (in Github) to apply commits to a different file? [closed]
For context: I'm part of a team that is in the beginning stages of developing a process to collaborate on code using Github. Recently, one of the individuals on the team opened up a PR for some changes made to 1 file, and when reviewing it, I saw that the Github diff logic indicated that every line of code was 'new'.
I did some digging and discovered that she had taken the file from a sub-folder, made some changes to it, and then saved a copy to the root directory, thus Git starting tracking this 'new' file.
I closed the PR, and asked her to make the changes to the file in the subfolder and then open a new PR.
I'm wondering this was the best way to address this issue, and if there is a Git command/feature in Github I could have employed to correct the issue (ie. is there a way to make Git 'apply' the changes to the correct file? Almost like a way to re-basing those new commits onto the right file?).
Any assistance/guidance would be much appreciated - please let me know if I'm not thinking about this issue in the right way!
Solution 1:[1]
you can use git patch functionality :
git diff HEAD^ -- my.txt > ~/patch_file
cd sub/
patch -p0 my.txt ~/patch_file
see patch for details what you can do. it is very powerful.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dmitry |
