DEV Community

Nesha Zoric
Nesha Zoric

Posted on β€’ Edited on

7 2

Git Commands Ultimate Tutorial Part 1

There are many different ways to use Git. The most common are the original command line tools and GUI (Graphical User Interfaces). Here, I will cover the most important commands you should know about when you are working with Git.

The command line is the only place you can run all Git commands. If you know how to run the command-line version you can probably also figure out how to run the GUI version. Also, while your choice of graphical client is a matter of personal taste, all users will have the command-line tools installed and available. You can read more on gits official online book.

Before we start, be sure to know how to use the Terminal in Mac or Command Prompt or Powershell in Windows and have git installed on your system.

Introduction

First, you might ask yourself what is Git actually and what can you do with it? Git is a fast, scalable, distributed **revision control system* with a rich command set that provides both high-level operations and full access to internals.*

In Kolosek, we use Git for every application we create, including Ruby on Rails projects, to make it easier to work as a team and achieve our goal.

You can learn a lot about individual Git commands by running $git help command in the Terminal. This should appear:

git-help-command

Everything can be added to your git repositories even your Controller tests!

Git Options

I will cover the most commonly used command lines, starting from Git options. This will explain everything you need to know about Git on your local machine:

usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path]
           [--info-path] [-p | --paginate | --no-pager]
           [--no-replace-objects] [--bare] [--git-dir=<path>]
           [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
Enter fullscreen mode Exit fullscreen mode
  • $git --version: Find out your current Git suite version using this command.

  • $git --help: Every good programmer should know about this option, it will show you the most used Git Commands, it can also print all available commands with --all or -a.

  • $git -C <path>: Instead of running Git from the current working directory, you can run it from the given <path> instead.

-C <path> command affects other options that expect path names like --git-dir and --work-tree because their path names would be made relative to the working directory caused by the -C option.

  • $git -c <name>=<value>: You can very easily override values from your configuration files. The <name> has to be in the same format as listed by git config, while the <value> is your new parameter value.

  • $git --exec-path[=<path>]: This command helps you find the path where your core Git programs are installed. Another way to do this is by setting the GIT_EXEC_PATH environment variable.

  • $git --git-dir=<path>: Always use this option, whenever you need to set a path to the repository or set the GIT_DIR environment variable.

We often used these Git options when we were setting up CarrierWave example to Git. Did you have a similar experience?

  • $git --work-tree=<path>: In this way, you can set the path to the current working tree. You can do this as well by setting the GIT_WORK_TREE environment variable.

  • $git --namespace=<path>: Set your Git namespace with this command or by using GIT_NAMESPACE environment variable.

And, that's it! For now, to be exact.

This was only the first part of the tutorial! In the next one, I will cover all the other Git commands, be sure to stay tuned.

This post is originally published on Kolosek Blog.

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo πŸ“Šβœ¨

Top comments (0)

PulumiUP 2025 image

PulumiUP 2025: Cloud Innovation Starts Here

Get inspired by experts at PulumiUP. Discover the latest in platform engineering, IaC, and DevOps. Keynote, demos, panel, and Q&A with Pulumi engineers.

Register Now

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay