Skip to content

Git Basics

Loky edited this page Oct 14, 2026 · 3 revisions

Git Basics: the commands behind Gitot

Gitot is a thin layer over the real git command. Every button runs one of the commands below, and everything is logged in the Gitot console. Learn these and you can do the same thing from a terminal. Full reference: git-scm.com/docs.

The mental model

Working tree  --stage-->  Index (staging)  --commit-->  Local history  --push-->  origin (GitHub)
 (your files)  <-unstage-                                              <--pull--
  • Working tree: your project files as they are on disk.
  • Index (staging area): the snapshot you are preparing for the next commit.
  • Commit: a saved snapshot with a message. Local until pushed.
  • Branch: a movable label on a commit. HEAD is the branch (or commit) you are on.
  • origin: the remote copy (GitHub). Upstream is the remote branch your branch tracks.

1. Daily workflow

Gitot action Command What it does
Initialize repository (no .git yet) git init -b main Creates the repository with a local main branch (Git 2.28+).
Add the remote (first Push) git remote add origin <url> Registers the GitHub repository as origin; the push that follows sets the upstream.
Status refresh git status --porcelain=v2 --untracked-files=all --no-renames (with --no-optional-locks) Lists changed, staged and untracked files (machine-readable format). The flag keeps the refresh from taking index.lock.
Stage git add -- <files> Moves changes into the index.
Unstage git reset -q -- <files> Removes files from the index. Your edits are kept. Also works before the first commit (git restore --staged needs one).
Unstage All git reset -q Same, for everything.
Commit git commit -m "<message>" Saves the index as a commit.
Amend git commit --amend --no-edit (or -m "<new message>") Rewrites the last commit. Safe only if it is not pushed yet.
Fetch git fetch origin Downloads remote changes, does not touch your files.
Pull git pull Fetch + merge the upstream into your branch.
Push git push -u origin HEAD Uploads your branch and sets its upstream (-u).
Push (diverged, confirmed) git push --force-with-lease -u origin HEAD Overwrites origin only if nobody pushed since your last fetch.

-- means "everything after this is a file name", which keeps odd names safe.

Ahead / behind: git rev-list --left-right --count @{u}...HEAD prints <behind> <ahead>. That is where the ↑/↓ counts come from. @{u} means "the upstream of the current branch".

Why Gitot refuses a force push when you are only behind: your branch has nothing new, so forcing would rewind origin and delete other people's commits. Pull first.

2. Branches

Gitot action Command
List (local + remote) git branch -a
Switch (double-click) git switch <branch>
Create (+) git switch -c <new> [<base>]
Check out a remote-only branch git switch -c <name> --track origin/<name>
Delete local git branch -d <branch>
Delete on origin git push origin --delete refs/heads/<branch>
  • -d (lowercase) refuses to delete a branch with unmerged commits. Gitot never uses -D.
  • Deleting on origin does not touch your local branch, and the other way around.
  • After a switch, Gitot runs git diff --name-only HEAD@{1} HEAD to learn which files changed, so only those are reloaded. HEAD@{1} is "where HEAD was before" (see the reflog below).

3. Stash (Shelf)

A stash parks your uncommitted work so you can switch context.

Gitot action Command
Stash git stash push -u [-m "<name>"] (-u also stashes untracked files)
List git stash list
Preview before pop git stash show --name-only --include-untracked --no-renames <stash>
Pop git stash pop <stash> (apply, then delete it if it applied cleanly)
Drop git stash drop stash@{n}

stash@{0} is the newest entry. If a pop hits a conflict, the stash is kept and you must fix the conflict markers by hand.

4. History, diff and restore

Gitot action Command
Commit history git log -n <10/20/30> (custom format)
Files of a commit git show --name-status --format= --no-renames <hash>
Diff of one file in a commit git show -U3 --format= --no-renames <hash> -- <path>
Working-tree diff (viewer) git diff -U3 --no-ext-diff HEAD -- <path>
Gutter markers git diff -U0 against HEAD
Restore file from a commit git restore --source=<hash> -- <path>

-U3 / -U0 set how many unchanged context lines surround each change (3 or none). A, M, D in the file list mean added, modified, deleted. Restore overwrites your uncommitted edits to that file.

5. Tags

A tag is a permanent label on a commit, typically a release.

Gitot action Command
Create (annotated) git tag -a <name> -m "<message>"
Push the tag git push origin <name>

Tags are not pushed by a normal git push, which is why Gitot pushes them in a second step.

6. Git LFS

Large binaries stored outside the normal history.

Gitot action Command
Detect state git lfs version, then git config --get filter.lfs.process
Install LFS git lfs install (global, once per computer)
Track / untrack a pattern git lfs track "<pattern>" / git lfs untrack "<pattern>"
Files list git lfs ls-files --json (and ... @{u} for origin)
Download git lfs pull
Prune git lfs prune

track writes a rule in .gitattributes. Commit that file, and only files committed afterwards are handled by LFS.

7. Console Info menu and recovery

Gitot action Command
Reflog git reflog -n 20
Repo size git count-objects -vH
Remote URL (for owner/repo) git remote get-url origin

The reflog is your safety net: it lists where HEAD has been, even after a reset or a branch deletion. Typical recoveries:

  • Deleted a local branch by mistake: find its tip in the reflog, then git switch -c <name> <sha>.
  • Deleted a branch on origin: Gitot logs the old tip, restore with git push origin <sha>:refs/heads/<name>.
  • Dropped a stash by mistake: its SHA is in the log, restore with git stash store <sha>.

Cheat sheet: terminal equivalent of a normal session

git status
git add -- scripts/player.gd
git commit -m "Fix jump"
git pull
git push -u origin HEAD

Next: Commit and Sync · Branches · Stash Manager · Git LFS

Clone this wiki locally