Copy a file including history from one repo to an other

Ralf Becker 2018-03-05 16:12:28 +01:00
parent 7163719006
commit e4ce919060

@ -51,3 +51,17 @@ or if you want to go back to latest previous commit:
git reset --hard HEAD^
```
> **IMPORTANT:** *reset with `--hard` parameter reset your commits and you may no longer have access to your changes.*
### Copy a file including history from one repo to an other
```
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > /tmp/commits.log
```
Fix the relative path to new repo
```
sed -i 's|path/to/file|new/path/to/file|g' /tmp/commits.log
```
Reapply it to new repo
```
cd /path/to/new/repo
git am < /tmp/commits.log
```