10 Git Commands Guaranteed To Boost Your Skills As A Developer

10 Git Commands Guaranteed To Boost Your Skills As A Developer

Supercharge your development with these 10 git commands

Git is the world’s most popular version control system. It was created by the infamous Linus Benedict Torvalds in 2005 to be a distributed version control system meant to track any changes in single computer files or huge computer files.

Fun fact: The name git means ( “unpleasant person” in British English slang) I guess Linus was trying to spite Bitkeeper for revoking its free license for Linux development.

In this article, I will list the 10 git commands I use most. Having these commands at my fingertips has made it easy to work on different stages of a project and also when contributing to open-source projects.

At the end of this article, you will have all you need to be a 10x developer.

Top 10 Commands

  1. git config

  2. git init

  3. git clone

  4. git add

  5. git commit

  6. git status

  7. git remote

  8. git push

  9. git pull

  10. git branch

git config

The git config command is used to set and get Git configuration values. These values can be stored in a global or local .gitconfig file.

The most common use for the git config command is to set configuration variables like the username and email address associated with your GitHub account.

This is usually the first thing to be done on a new machine before access is granted to push to git.

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

git init

Git init creates a new git repository in the current directory. It creates a hidden file (.git) that contains all of the necessary metadata, such as objects, refs, and template files.

git init

git clone

The git clone command creates a copy of an existing Git repository, including all files, branches, and commits. This can be used to back up a repository or create a local copy of a remote repository.

git clone <repository url>

git add

Git adds staged changes to files in your working directory for the next commit. You can use it to stage individual files, directories, or the entire working directory.

git add <file name>  adds a single file
git add .       adds the entire working directory

git commit

Git commit saves your work by creating a snapshot of your project's current state. This snapshot is called a commit, and it includes the changes you have made to your project since the last commit. This command also requires you to write a commit message about what your changes are all about.

git commit -m "Commit message"

git status

The git status command is used to display the current status of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by git.

git status

git remote

Git remote is used to link your local repository to the remote server. It can be used to add, remove and update the repository from the remote server.

git remote add <name> <url>

git push

The git push command is used to send local commits to the remote repository. Flags can be set to determine which branch to push local commits to.

git push <remote> <branch>

git pull

Git pull updates your current working branch directly with that of the remote server. This allows your current working branch to stay up to date with the remote server.

git pull <remote> <branch>

git branch

The git branch command lists, renames, and deletes branches. Branches allow you to versions of a project without touching the main branch that might be in production.

git branch  displays all branches.

git branch <branch name> creates a new branch.

git branch -d <branch name> deletes a branch.

I know I know, I said 10 but an extra one doesn't hurt anyone, right?

git checkout

The git checkout command can be used to switch between branches. This command also allows you to create a new branch and switch to that branch with one command.

git checkout <branch name>  changes to branch.

git checkout -b <branch name> creates a new branch and switches to it.

Conclusion

You have just learned that will supercharge your development skills. Just like every skill practice is important so incorporate some of these git commands into your daily workflow and you will master them before you know it.

If you found reading this blog post valuable then please like, share with friends, and follow me to get updates for my upcoming post.