On Tue, 27 Sep 2016 05:12:35 -0700 (PDT)
Neil Nand <cli...@neilnand.co.uk> wrote:

> I have a client that wishes to have some functionality removed from a 
> website that I'm building but I'm not totally convinced they won't
> want the functionality added back to the site at a later date.
> Is there a way to handle this type of situation with git? Basically 
> deleting code in one commit then easily finding that code again in
> the future (potentially months or years from now) to either restore
> or use as a reference for reimplementing it if the site has changed
> to much for it to be directly restored.
> I realise in code I can use if an if statement, comment it out or
> various other ways to achieve this but I wanted to see if it can be
> handled just with git as retrieving previously deleted code seems
> like the find of thing a VCS should be better at handling.

You can roll like this:

1. Attach an annotated tag to the top (last) commit containing the
   change the client wants to be removed.

   Give it a meaningful name and in the annotation, explain clearly
   what this tag is about.

1. Remove the offending change.

   Either to it by hand, or, if that change was specifically introduced
   by a commit or a series of commits, you can use `git revert` which
   records a new commit which textually undoes the specified changes.

When the client wants their feaure back, you can easily find it by that

Getting it back would amount to cherry-picking the change of that
tagged commit.  If the change spans several commits, you could
cherry-pick all of them.

If you did `git revert`, it's possible to `git revert` the revert
commit itself -- which effectively brings the reverted changes back.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to