I recently forgot to pull the most recent version of my remote to my local before I made a commit. No big deal I'll just stash my changes then pull from remote. This resulted in a conflict with one of the files, and I also noticed that many other files were staged. So I resolved the conflict and then removed all the files from the staging area (I didn't know anything about them) except the file that I resolved the conflict on, lastly I committed and pushed what I thought was that single file.
Turns out my understanding of how git works is flawed, and I pushed the snapshot of my local workspace (without the many other files from the remote that I was trying to fetch and merge). This effectively removed those files from the remote branches new head (my commit)
My guess is these questions have been asked before but I wasn't able to find them so here goes:
Is staging files required? If git just commits a snapshot of your whole local workspace anyways, why index anything? Lastly is there a command (I could create an alias) that wraps pull and commit, so that I don't forget to pull before committing again, so it would fetch, merge, commit? Or is there a reason the command doesn't exist?
thanks for your time