I generated a patch file using git, but now I want to manually add in a new file into the patch. Its just a text file with one line. I copied another section of the patch file that creates a new file, but I don't know what to put for the line that says "index". See my screen shot. I'm guessing its a hash of the new file? Is this index line necessary?
Asked
Active
Viewed 287 times
0
-
https://stackoverflow.com/search?q=%5Bgit%5D+diff+file+format – phd Jun 16 '20 at 19:25
-
Therere 2 hashes (`0000000` for old hash means it's a new file) and file mode. – phd Jun 16 '20 at 19:26
-
it doesn't answer my question. do i need the index line or not? what do i put there if i'm just creating a blank file in the patch? – Patoshi パトシ Jun 16 '20 at 19:29
-
Blank file has a hash. – phd Jun 16 '20 at 19:30
-
so the line should look like: **index 0000000..0000000** ? – Patoshi パトシ Jun 17 '20 at 20:42
-
SHA1 hashes are [calculated in Git for database objects which have headers and data](https://stackoverflow.com/a/35433095/7976758) (https://stackoverflow.com/search?q=%5Bgit%5D+calculate+hash). An empty file is stored in the DB as blob with header `blob 0\0` (first `0` is file length, `\0` is NULL that separates headers from data) and no data. The hash for the blob of the empty file is `echo -en 'blob 0\0' | sha1sum` -> `e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`. So the line should look like `index 0000000..e69de29 100644` – phd Jun 17 '20 at 21:14