GitAlias / gitalias

Git alias commands for faster easier version control
2.43k stars 325 forks source link

Alias suggestion `apply-gitignore` #98

Open felipecrs opened 11 months ago

felipecrs commented 11 months ago

Applies gitignore to all files (remove files which were previously committed already).

apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f"

What do you think?

joelparkerhenderson commented 11 months ago

I understand the intent. I've done similar many times to fix accidents with a .gitignore file not being ready or complete.

In general, for this repo, can you consider if there are any ways to adjust the alias in these kinds of ways...?

felipecrs commented 11 months ago

I'm just nervous about the last item:

can you do less (i.e. alias to do the rm cached, which would then let typical add aliases and add commands to work as expected)?

If I remove the git add . command, then the alias becomes something else completely.

joelparkerhenderson commented 11 months ago

Naming is hard. :-)

As an example, when I first read your alias name apply-gitignore, what I anticipated was to provide stdin (because apply can mean apply a function to each input) and append each line to the .gitignore file.

Of course your code is totally different in purpose.

What happens when you ask some developers for opinions and brainstorms of naming ideas?

Maybe some naming brainstorms could involve concepts of redo or undo, repair or fix, "oops", or similar...?

felipecrs commented 11 months ago

Oh for sure, I didn't like the name very much but I could not think of something better either.

I am happy to iterate through it as many times as needed. :)