Re: Retrieving a file in git that was deleted and committed

2018-12-11 Thread Jeff King
On Mon, Dec 10, 2018 at 01:33:18PM -0800, Elijah Newren wrote: > Hmm...sure, if the file is deleted on the only relevant branch through > history...but what if there were another branch where it weren't > deleted? What does git blame do then? > > In other words, do NOT restore the file as biswar

Re: Retrieving a file in git that was deleted and committed

2018-12-10 Thread Junio C Hamano
Jeff King writes: > You can feed a set of revisions to git-blame with the "-S" option, but I > don't offhand know how it handles diffs (I think it would have to still > diff each commit against its parent, since history is non-linear, and a > list is inherently linear). It would diff each commit

Re: Retrieving a file in git that was deleted and committed

2018-12-10 Thread Elijah Newren
On Thu, Dec 6, 2018 at 11:48 PM Jeff King wrote: > > On Thu, Dec 06, 2018 at 11:07:00PM -0800, biswaranjan panda wrote: > > > Thanks! Strangely git log --follow does work. > > I suspect it would work even without --follow. When you limit a log > traversal with a pathspec, like: > > git log foo >

Re: Retrieving a file in git that was deleted and committed

2018-12-10 Thread Sergey Organov
biswaranjan panda writes: > I have the following scenario: > > On a branch A, I deleted a file foo.txt and committed the change. Then > I did a bunch of other changes. > Now I want to undelete foo.txt. [...] > I would appreciate if anyone knows how to preserve git blame history. Provided you d

Re: Retrieving a file in git that was deleted and committed

2018-12-08 Thread biswaranjan panda
>You can feed a set of revisions to git-blame with the "-S" option, but I >don't offhand know how it handles diffs (I think it would have to still >diff each commit against its parent, since history is non-linear, and a >list is inherently linear). You might want to experiment with that. >Other th

Re: Retrieving a file in git that was deleted and committed

2018-12-07 Thread Jeff King
On Fri, Dec 07, 2018 at 01:50:57PM -0800, biswaranjan panda wrote: > Thanks Jeff and Bryan! However, I am curious that if there were a way > to tell git blame to skip a commit (the one which added the file again > and maybe the one which deleted it originally) while it walks back > through history

Re: Retrieving a file in git that was deleted and committed

2018-12-07 Thread biswaranjan panda
On Thu, Dec 6, 2018 at 11:26 PM Jeff King wrote: >> >> On Thu, Dec 06, 2018 at 11:07:00PM -0800, biswaranjan panda wrote: >> > >> Thanks! Strangely git log --follow does work. >> >> I suspect it would work even without --follow. When you limit a log >> traversal with a pathspec, like: >> >> git

Re: Retrieving a file in git that was deleted and committed

2018-12-06 Thread Bryan Turner
On Thu, Dec 6, 2018 at 11:26 PM Jeff King wrote: > > On Thu, Dec 06, 2018 at 11:07:00PM -0800, biswaranjan panda wrote: > > > Thanks! Strangely git log --follow does work. > > I suspect it would work even without --follow. When you limit a log > traversal with a pathspec, like: > > git log foo >

Re: Retrieving a file in git that was deleted and committed

2018-12-06 Thread Jeff King
On Thu, Dec 06, 2018 at 11:07:00PM -0800, biswaranjan panda wrote: > Thanks! Strangely git log --follow does work. I suspect it would work even without --follow. When you limit a log traversal with a pathspec, like: git log foo that is not about following some continuous stream of content, bu

Re: Retrieving a file in git that was deleted and committed

2018-12-06 Thread biswaranjan panda
Thanks! Strangely git log --follow does work. On Thu, Dec 6, 2018 at 10:55 PM Bryan Turner wrote: > > On Thu, Dec 6, 2018 at 10:49 PM biswaranjan panda > wrote: > > > > I have the following scenario: > > > > On a branch A, I deleted a file foo.txt and committed the change. Then > > I did a bunch

Re: Retrieving a file in git that was deleted and committed

2018-12-06 Thread Bryan Turner
On Thu, Dec 6, 2018 at 10:49 PM biswaranjan panda wrote: > > I have the following scenario: > > On a branch A, I deleted a file foo.txt and committed the change. Then > I did a bunch of other changes. > Now I want to undelete foo.txt. > > One way is to checkout a separate branch B where the file i

Retrieving a file in git that was deleted and committed

2018-12-06 Thread biswaranjan panda
I have the following scenario: On a branch A, I deleted a file foo.txt and committed the change. Then I did a bunch of other changes. Now I want to undelete foo.txt. One way is to checkout a separate branch B where the file is present. Then checkout A. Then do git checkout B -- path_to_file Whil