Git: add vs push vs commit

Smita Sen
Catalysts Reachout
Published in
2 min readOct 16, 2022

First let me tell you about Git and GitHub in case you are unaware of it. Git is a version control system that lets you manage and keep track of your source code history, thus, you can view specific versions of those files later on. GitHub is a cloud-based hosting service that lets you manage Git repositories.

While using git commands, if you also get confused, You are not alone. Many people mix up these.

In order to understand Git you would need to invest more effort than just glancing over the documentation, but it’s definitely worth it. Here, I am clarifying things.

  1. git add adds your modified files to the queue to be committed later. Files are not committed. It selects changes. It is used to tell git which files we want to commit, it puts files to the staging area.
  2. git commit commits your current changes on your local repository. It records changes LOCALLY. It is used to save files on to local machine so that if we make any changes or even delete the files we can still recover our committed files.
  3. git push pushes your changes to the remote repository. It shares changes. If we commit our files on the local machine they are still prone to be lost if our local machine gets lost, gets damaged, etc. to keep our files safe or to share our files usually we want to keep our files on a remote repository like GitHub. To save on remote repositories we use push.

I hope it’s clear now. Happy Learning!!

--

--