By admin , 28 April 2026

Introduction

Git rewards command-line fluency. A few small habits make day-to-day work dramatically faster and safer. This page collects the highest-impact tips for new users.

Always know where you are

Add Git status to your shell prompt. Bash and Zsh both ship contrib scripts:

# bash
source /usr/share/git/completion/git-prompt.sh
PS1='\w$(__git_ps1 " (%s)")\$ '

# zsh with oh-my-zsh: enable the git plugin in ~/.zshrc

Now the current branch and dirty state are visible at all times.

By admin , 28 April 2026

Introduction

Tags are named references to specific commits. Unlike branches, tags are not meant to move. They are perfect for marking releases (v1.0.0) and other historical points.

By admin , 28 April 2026

Introduction

Git provides several ways to undo, depending on whether the change is in your working tree, in the index, in your latest commit, or already pushed. Choosing the right tool prevents accidents.

Discarding working-tree edits

You edited a file but want to throw the changes away:

git restore file.txt              # modern
git checkout -- file.txt          # classic equivalent

git restore with no --source uses the index, so the file returns to its last git add state.

By admin , 28 April 2026

Introduction

A merge combines two lines of development. The most common case is bringing a feature branch back into main. This page walks through a clean merge, a fast-forward, and a conflicted merge.

By admin , 28 April 2026

Introduction

Branches are how Git supports parallel lines of work. Creating a branch is essentially free: it is just a 41-byte file containing a commit hash. Use them generously for features, experiments, and bug fixes.

Modern commands

Since Git 2.23 there are two purpose-built commands: git switch for branches and git restore for files. Use them; they are clearer than git checkout's overloaded behaviour.

By admin , 28 April 2026

Introduction

HEAD is the most important reference in Git. It tells Git which commit your next commit will descend from. Most of the time HEAD points at a branch, and that branch points at a commit; but HEAD can also point directly at a commit (detached HEAD).

Where it lives

HEAD is a single file at .git/HEAD. Inspect it:

By admin , 28 April 2026

Introduction

git push uploads local commits to a remote and updates that remote's branches and tags. It is how your work becomes visible to collaborators.

Basic push

git push                          # current branch to its upstream
git push origin main              # explicit
git push -u origin feature/login  # set upstream and push

The -u (or --set-upstream) flag links the local branch to the remote one so future git push and git pull need no arguments.

By admin , 28 April 2026

Introduction

git fetch downloads new objects and updates remote-tracking refs without changing your working tree. git pull does a fetch and then integrates the result into your current branch. Knowing the difference is one of the biggest steps from novice to confident Git user.

By admin , 28 April 2026

Introduction

A remote is a named URL pointing to another Git repository. git clone creates one called origin automatically, but you can add as many as you like. Remotes are the bridge between your local repo and the outside world.

Listing and inspecting

git remote
git remote -v
git remote show origin

git remote show contacts the server and reports tracked branches, push rules, and stale refs.

By admin , 28 April 2026

Introduction

git clone copies a remote repository to your machine. It creates a new directory, initializes .git inside it, fetches all objects and refs, sets up a remote called origin, and checks out the default branch. After cloning you have a complete, independent repository.