spacetelescope / style-guides

An opinionated guide on how we work.
Creative Commons Attribution 4.0 International
55 stars 33 forks source link

Avoid git commit -am #70

Closed pllim closed 5 years ago

pllim commented 5 years ago

I have seen many people bitten by the -am option. I am suggesting something easier to undo.

p.s. Not sure why my Emacs generated diff in L3. Maybe it is fixing some pesky endline character added by Mac.

arfon commented 5 years ago

👍

jamienoss commented 5 years ago

-a only auto stages already tracked files. If tracked files are changed, why do said changes not want to be committed?

git docs

"Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected."

Using git add <file>, in this context, passes repsonsibility to the user rather than letting git manage this for you, e.g. what happens when you forget to explcitly add a file to stagging?

jamienoss commented 5 years ago

FYI - I use git commit -a all of the time, as my default workflow. The only time I use git add is to:

1) track new files 2) stage changes that I do not want to be explcitly responsible for commiting, e.g. resolving merge/rebase conflicts.