Git commands I use the most in my Daily work

Git is a wonderful tool for getting your code under control, make changes securely and when you’re working with a team is the best way to keep your project updated without any conflicts. Here are the Git commands I use the most daily:

Git Clone

I use Git clone for downloading the existing source code from Github. It makes an identical copy of the latest version of a project in a repository and saves it to your computer. You just need to look for a project from Github, copy the link from the green button Clone or download:

Next, use this url with the git clone command as follows:

git clone

Git Add

This command is to include the changes of a file(s) into your next commit.

You can add a single file:

git add newfile.txt       

Or you can add all the changes at once:

git add -A

Git commit

This command is used to confirm all changes made on your repository once you have finished a task or new feature. It is like setting a checkpoint in which you can go back later if needed.

git commit -m "new commit"

The -m flag is for setting a message with information about your commit

Git status

It gives me information about the branch I’m currently working with, such as if my branch is up to date or if there is anything to commit, push or pull, files created, modified, etc.

Git push

It is used for sending the committed changes to the remote server. Git push uploads your commits to the remote repository for example Github.

git push origin master

Where origin is your remote branch and master is your current local branch you want to be uploaded.

Git pull

This command is used to download the latest version from the remote repository. It is useful when you’re working with a team and you want to get all the updates made by them.

Git branch

Branches are used to work in parallel in the same project simultaneously without making changes to the principal permanent version of the project. This way you can safely make changes, try updates or new features, test them and at the end, if everything goes fine, merge these changes to the principal branch (master)

This command creates a new branch:

git branch <branch-name>

List existing branches on your local repository:

git branch --list

Delete a branch on your repository:

git branch -d <branch-name>

Git checkout

It is used for switching from one branch to another. You must commit the changes to your current branch before you use this command.

 git checkout <branch-name> 

Deja un comentario