BASIC GIT COMMANDS that you should know if you are a developer.


What is GIT?

It is a “Version Control” software, which makes it easy for users to keep track of changes to a file.

Git is one of the most indispensable tools for project development.


Let get started!

1- git init
* Start a new repository

> git init


2- git clone
* Clone an existing repository, download a project and its entire version history

> git clone <https://link-with-repository-name>


3- git add and variations
* Add files to staging area

> git add <file-name> // Add a specific file.
> git add . // Add all files.


4- git commit -m
* Commit the changes with a message explaining the changes

> git commit -m “commit message”
> git commit -a -m “skip git add” // With this command we skip doing git add


5- git status
* Lists all new or changed files that need to be committed

> git status -s


6- git log
* List the version history of the current branch.

> git log
> git log –oneline –graph // With this command you can see it much better
> git log –pretty=oneline –graph –decorate –all // Another more complete way


7- git push
* Upload the files to a remote repository

> git push origin main


8- git pull
* Merge all changes that have been made in the local repository with the local working directory

> git pull


9- git branch or git checkout -b
* Create a new branch

> git branch <branch-name>

* Create a branch branch (Second option)

> git checkout -b <branch-name> // Will create the new branch and switch to it instantly


10- git branch -d
* Delete a Branch

> git branch -d <branch-name>


11- git checkout
* Switch to the specified branch and update the active directory

> git checkout <branch-name>


Thanks for reading!

Gastón Danielsen

Full stack developer