'Will successive add + remove commits stay in the history?

I've just written myScript.sh, which fixes something specific at this point in time in my project and will do nothing after being executed once.

Since all our code is tracked in Git, and to share it with colleagues, I want to commit it : it's important for us to know what piece of code was run and when it was run. But since it's a single-use script, I also prefer to remove it so that it won't clutter our workspaces.

So I'll have 2 successive commits :

commit1 : ADD myScript.sh to do foo bar

commit2 : DELETE myScript.sh which did its job and is not necessary anymore

Will myScript.sh stay as-is in Git history (invisible in the working area but still available for a future checkout, which is fine to me) or are there any "housekeeping" functionalities of Git that will detect the successive add + remove commits and just discard both ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source