Git Commands

While learning Git I have found these commands my most used:

git init

This command initialize a repository or reinitialize an existing one

git status

will display the state of the current branch you are working in and whether they are tracked or not

git add

this will add files ready to be pushed to the repository. you can do:

git add <file name>

or all files with

git add .

git switch

will change which branch you are working in. this command will also work as “git checkout” if a new branch is need to be added it can made like:

git checkout -b <branch name>

git branch

this will list out all the branches currently

git pull

will get any updates from the repository and merge to the local

git commit

once changes are made and files are added to the commit we just this command to attach them to the current branch, a message can be added to it like so:

git commit -m “<commit message>”

git push

this will push our changes to the remote branch and can be done like this:

“git push origin main”



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store